I was in the branch mybranch1
. mybranch2
From mybranch1
it bifurcated, and mybranch2
has been in mybranch2
.
Then, mybranch1
I've done git merge --no-commit mybranch2
it shows there is a conflict consolidation.
Now I want to discard all things ( merge
command) in order to mybranch1
return to a previous state. I do not know how to do.
#1st Floor
In fact, it is worth noting that git merge --abort
only about git reset --merge
because MERGE_HEAD
there is. This can be read in git help for merge command.
git merge --abort # is equivalent to git reset --merge when MERGE_HEAD is present.
After the merger fails, when no MERGE_HEAD
, you can use git reset --merge
merge undo failure, but not necessarily to use git merge --abort
, so they are not only the old and the same syntax as something new .
Personally, I find that git reset --merge
more useful in their daily work.
#2nd Floor
The latest Git:
git merge --abort
This will attempt to reset your working copy to the state before the merger. This means that it should recover any uncommitted changes from before the merger, although it does not always reliably do this. Normally, you should not change the merge is not submitted.
Prior to version 1.7.4:
git reset --merge
This is the older syntax, but the same as above.
Prior to version 1.6.2:
git reset --hard
It will remove all uncommitted changes, including mergers uncommitted. Sometimes, even in the above command support for newer versions of Git This behavior is also useful.
#3rd floor
Suppose you are using the latest git,
git merge --abort