Derek Hill
Derek Hill

Reputation: 6454

Unstage all files and abandon merge

I was running a simple merge and expecting no conflicts, and I ran git merge my_dev_branch

However I got a merge conflict which looked messy to resolve, and made me think that I wasn't clear on my branch history. Rather than resolve the conflict I would like to abandon the merge and go back to where I was before.

Two questions:

  1. Am I right in thinking that I could clean out my staging area by running git checkout HEAD <filename> on each file per this question and that this would amount to abandoning the merge?
  2. Is there a way I can do this in one command?

Upvotes: 37

Views: 10648

Answers (1)

Jamey Sharp
Jamey Sharp

Reputation: 8511

Try git merge --abort. Handy, eh?

Upvotes: 76

Related Questions