Quantcast
Viewing latest article 7
Browse Latest Browse All 10

Answer by errordeveloper for Undo a merge by pull request?

There is a better answer to this problem, though I could just break this down step-by-step.

You will need to fetch and checkout the latest upstream changes like so, e.g.:

git fetch upstreamgit checkout upstream/master -b revert/john/foo_and_bar

Taking a look at the commit log, you should find something similar to this:

commit b76a5f1f5d3b323679e466a1a1d5f93c8828b269Merge: 9271e6e a507888Author: Tim Tom <tim@tom.com>Date:   Mon Apr 29 06:12:38 2013 -0700    Merge pull request #123 from john/foo_and_bar    Add foo and barcommit a507888e9fcc9e08b658c0b25414d1aeb1eef45eAuthor: John Doe <john@doe.com>Date:   Mon Apr 29 12:13:29 2013 +0000    Add barcommit 470ee0f407198057d5cb1d6427bb8371eab6157eAuthor: John Doe <john@doe.com>Date:   Mon Apr 29 10:29:10 2013 +0000    Add foo

Now you want to revert the entire pull request with the ability to unrevert later.To do so, you will need to take the ID of the merge commit.

In the above example the merge commit is the top one where it says "Merged pull request #123...".

Do this to revert the both changes ("Add bar" and "Add foo") and you will end up with in one commit reverting the entire pull request which you can unrevert later on and keep the history of changes clean:

git revert -m 1 b76a5f1f5d3b323679e466a1a1d5f93c8828b269

Viewing latest article 7
Browse Latest Browse All 10

Trending Articles