How to undo the conflict git merge

I was in the branch mybranch1. mybranch2From mybranch1it bifurcated, and mybranch2has been in mybranch2.

Then, mybranch1I've done git merge --no-commit mybranch2it shows there is a conflict consolidation.

Now I want to discard all things ( mergecommand) in order to mybranch1return to a previous state. I do not know how to do.


#1st Floor

In fact, it is worth noting that git merge --abortonly about git reset --mergebecause MERGE_HEADthere 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 --mergemerge 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 --mergemore 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
Original articles published 0 · won praise 0 · Views 2246

Guess you like

Origin blog.csdn.net/p15097962069/article/details/103873430