Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)

I am on branch mybranch1.mybranch2 is forked from mybranch1 and changes were made in mybranch2.

Then, while on mybranch1, I have done git merge --no-commit mybranch2 It shows there were conflicts while merging.

Now I want to discard everything (the merge command) so that mybranch1 is back to what it was before. I have no idea how do I go about this.

1 Answer

0 votes
by (50.2k points)

For the latest versions of git 

Git merge --abort # this will allow you to undo merge conflicts.

This attempts to reset your working copy to whatever state it was in before the merge. That means that it should restore any uncommitted changes from before the merge, Generally, you shouldn't merge with uncommitted changes anyway.

For prior versions we use 

version 1.7.4:

git reset --merge

This is equivalent to the present syntax

Before version 1.6.2:

git reset --hard

which removes all uncommitted changes, including the uncommitted merge.

Hope this information will help you to resolve your query.

Browse Categories