Rollback a git merge

develop branch --> dashboard (working branch) 

I use git merge --no-ff develop to merge any upstream changes to the panel

git log:

 commit 88113a64a21bf8a51409ee2a1321442fd08db705 Merge: 981bc20 888a557 Author: XXXX <> Date: Mon Jul 30 08:16:46 2012 -0500 Merge branch 'develop' into dashboard commit 888a5572428a372f15a52106b8d74ff910493f01 Author: root <root@magneto.giveforward.com> Date: Sun Jul 29 10:49:21 2012 -0500 fixed end date edit display to have leading 0 commit 167ad941726c876349bfa445873bdcd475eb8cd8 Author: XXXX <> Date: Sun Jul 29 09:13:24 2012 -0500 

There were about 50+ commits in the merge, and I wonder how easy it is to return the merge, so the toolbar returns to the preliminary merge of states

The second part of this, if I am not going to merge with --no-ff , I do not get a commit Merge the 'develop' branch into my dashboard . How do I flip this drain back?

+158
git
Jul 30 '12 at 13:24
source share
4 answers

Merge transaction returns are comprehensively covered in other matters. When you perform a quick switch, the second one you are describing, you can use git reset to return to the previous state:

 git reset --hard <commit_before_merge> 

You can find <commit_before_merge> with git reflog , git log or if you feel moxy (and haven’t done anything): git reset --hard HEAD@{1}

+241
Jul 30 '12 at 13:32
source share

From here:

http://www.christianengvall.se/undo-pushed-merge-git/

 git revert -m 1 <merge commit hash> 

Git revert adds a new commit that rolls back the specified commit.

Using -m 1 reports that this is a merge, and we want to return to the parent commit on the main branch. You should use -m 2 to specify the development branch.

+95
Jul 29 '15 at 10:24
source share

Just reset the merge with git reset --hard HEAD^ .

If you use --no-ff git, a merge is always created, even if you haven’t done anything between them. Without --no-ff, git will just do fast forward, i.e. your HEAD branches will be set to the HEAD of the merged branch. To solve this problem, find the commit identifier you want to return to and git reset --hard $COMMITID .

+16
Jul 30 '12 at 13:30
source share

git reset -m 1 88113a64a21bf8a51409ee2a1321442fd08db705

 git revert -m 1 88113a64a21bf8a51409ee2a1321442fd08db705 

But they can have unexpected side effects. See --mainline parent-number at git-scm.com/docs/git-revert

Perhaps a rude but effective way would be to check the left parent of this commit, copy all the files, extract the HEAD again, and replace all the contents with the old files. Then git will tell you that it is rolling back and you will create your own return commit :)!

+5
Mar 17 '15 at 21:36
source share



All Articles