git-revert

I need to pop up and trash away a “middle” commit in my master branch. How can I do it?

梦想的初衷 提交于 2019-12-17 17:26:30
问题 For example, in the following master branch, I need to trash just the commit af5c7bf16e6f04321f966b4231371b21475bc4da, which is the second due to previous rebase: commit 60b413512e616997c8b929012cf9ca56bf5c9113 Author: Luca G. Soave <luca.soave@gmail.com> Date: Tue Apr 12 23:50:15 2011 +0200 add generic config/initializers/omniauth.example.rb commit af5c7bf16e6f04321f966b4231371b21475bc4da Author: Luca G. Soave <luca.soave@gmail.com> Date: Fri Apr 22 00:15:50 2011 +0200 show github user info

What should I do when git revert aborts with an error message?

一个人想着一个人 提交于 2019-12-17 16:24:32
问题 OK, so I'm getting an error sometimes when I try to revert a commit (with Git). All that I do is git revert <commit hash> and it gives me this message: error: could not revert <commit hash> <commit message> hint: after resolving the conflicts, mark the corrected paths hint: with 'git add <paths>' or 'git rm <paths>' Does this mean that I should use git mergetool and resolve any conflicts? Once I do this can I add/rm and then commit, and the revert is complete? 回答1: Yes you will have to

How to revert multiple git commits?

一曲冷凌霜 提交于 2019-12-16 20:05:09
问题 I have a git repository that looks like this: A -> B -> C -> D -> HEAD I want the head of the branch to point to A, i.e. I want B, C, D, and HEAD to disappear and I want head to be synonymous with A. It sounds like I can either try to rebase (doesn't apply, since I've pushed changes in between), or revert. But how do I revert multiple commits? Do I revert one at a time? Is the order important? 回答1: Expanding what I wrote in a comment The general rule is that you should not rewrite (change)

GET pull request merge commit sha from pull request number using github api

折月煮酒 提交于 2019-12-12 10:42:55
问题 I'm trying to use the github api (via githubot https://github.com/iangreenleaf/githubot) to GET a pull request merge commit sha from the pull request number. I'm able to get the proper response (example here under "get a single pull request": https://developer.github.com/v3/pulls/) but the merge_commit_sha gives me this error: fatal: bad object 304fc816f33f808080c9c87895eea2d66081d373 When I compare the 2 pages on github I'm seeing both the merge_commit_sha from the commit page but I'm seeing

Can you ever revert a commit other than the very last without creating a conflict?

邮差的信 提交于 2019-12-10 20:29:07
问题 Note: stackoverflow's bot thinks the question is subjective but it is very factual - I am not asking for opinions here! Let's say that I have one branch only, and the history of my commits are: A - B - C - D If I click on C in a GUI (like GitKraken or Git for Windows) and do "revert commit", I get a file conflict message. Two questions: Is this because the revert "undoes" the changes made in C, and GIT is now stuck with B and D which modify the file in different, incompatible ways? is that

After reverting a file to a previous revision git diff shows no differences?

半城伤御伤魂 提交于 2019-12-10 18:22:56
问题 After reverting a file to a previous revision in git git checkout abcdefg myfile git diff myfile <-- shows no results. 回答1: The revert pulls changes to staging so you have to use git diff --cached myfile 来源: https://stackoverflow.com/questions/34051174/after-reverting-a-file-to-a-previous-revision-git-diff-shows-no-differences

Revert only a single file of a pushed commit

随声附和 提交于 2019-12-07 15:48:50
问题 Below is the the pushed commits history. Commit Changed Files Commit 1| (File a, File b, File c) Commit 2| (File a, File b, File c) Commit 3| (File a, File b, File c) Commit 4| (File a, File b, File c) Commit 5| (File a, File b, File c) I want to revert the changes happened to File b of Commit 3 . But i want the changes happened to this file in commit 4 and 5. 回答1: In Git, each commit saves a snapshot —that is, the state of every file—rather than a set of changes. However, every commit—well,

Revert pushed branch to a concrete commit

爷,独闯天下 提交于 2019-12-07 08:12:18
问题 I have merged a dev branch (with constant, sometimes unstable changes) to our master branch (where we store the released, stable code). I want to restore the master branch to the state it was before like the merge with the dev branch had never happened (and that when in the future we merge the dev branch all changes that we will discard now will be merged "again"). This is the current status of the master branch and I want it to have the 'professional-1.1.2' commit/tag at the HEAD. I tried: $

How to cherry pick commits after they've been reverted?

a 夏天 提交于 2019-12-07 02:42:48
问题 I was working on my feature branch and after review, merged it into development to be deployed. Later, a coworker decided to do a release and merged his and mine into master . While deploying he realized his code was buggy and reverted master . In our fork-and-pull flow, that means that now development and master are both reverted. When I came in this morning, I rebased from development per usual, to learn afterward there had been a revert. Now I'm trying to cherry-pick my work from the

Revert pushed branch to a concrete commit

江枫思渺然 提交于 2019-12-05 12:40:47
I have merged a dev branch (with constant, sometimes unstable changes) to our master branch (where we store the released, stable code). I want to restore the master branch to the state it was before like the merge with the dev branch had never happened (and that when in the future we merge the dev branch all changes that we will discard now will be merged "again"). This is the current status of the master branch and I want it to have the 'professional-1.1.2' commit/tag at the HEAD. I tried: $ git revert -n professional-1.1.2..HEAD fatal: Commit 9167e846a387c793edbc089c7ab6bd9eb8260456 is a