On a git-svn
checkout I accidentally merged a branch onto trunk
:
git checkout -b my_branch
# make and commit changes
git checkout trunk
git svn rebase
git merge my_branch
# resolve conflicts
I did not dcommit
yet but to me it looks like now I've lost the original trunk
and have a shuffled commit history:
$ tig
2016-09-19 15:09 other-dev o {trunk} remote changes
2016-09-19 15:01 me o changes on my_branch
2016-09-19 14:55 other-dev o remote changes
2016-09-19 14:33 me o changes on my_branch
2016-09-19 13:58 me o changes on my_branch
2016-09-19 13:44 other-dev o remote changes
2016-09-19 11:48 me o changes
2016-09-16 07:41 other-dev o changes
I now think bad things will happen if I try to dcommit
this state.
I'd like to 'undo' the whole merge, go back to my_branch
, rebase trunk
and re-do the merge.
The only idea I come up with is to checkout remote/trunk
, delete local/trunk
and re-branch local/trunk
from remote/trunk
.
Is there an easier way to 'undo' a merge in this case?
I wonder why tig
is not showing the merge actually. I tried to reproduce this and tig
tries ordering the commits by date, even from different branches. But with the branch view it shows to me the branch like:
2016-09-20 13:31 me M─┐ [master] Merge branch 'foo'
2016-09-20 13:31 me o │ f
2016-09-20 13:30 me │ o [foo] e
2016-09-20 13:29 me o │ d
2016-09-20 13:28 me o │ c
2016-09-20 13:27 me │ o b
2016-09-20 13:17 me I─┘ a
and if I switch off branch view with 'G'
2016-09-20 13:31 me [master] Merge branch 'foo'
2016-09-20 13:31 me f
2016-09-20 13:30 me [foo] e
2016-09-20 13:29 me d
2016-09-20 13:28 me c
2016-09-20 13:27 me b
2016-09-20 13:17 me a
similar to yours, except that there are no o
commit markers and the merge commit is shown.
Besides that, just look at the reflog of master
with git reflog master
to find the SHA of the master commit before your merge and then simply reset master to that commit with git reset --hard <good commit-ish>
while having master
checked out, or git branch -f master <good commit-ish>
if you are not on master and don't want to check it out right now.