I have merged master
into my bugXY
branch, and needed to merge a file. But git mergetool
failed (my noob fault, I guess), and even though I aborted the merge it left me with a dirty working directory but not in need-to-merge state. I would like to repeat the merge command, but I can't due to some new files left by the merge.
How can I undo the merge (I didn't commit anything) and get exactly the working directory from before?
What I did:
> git checkout bugXY
On branch "bugXY" - nothing to commit
> git merge master
[modifying and adding lots of files]
one file with conflict
On branch "bugXY|MERGING"
> git mergetool
You could use a, b or c
merged // didn't work, no GUI appeared and I did not do anything
do you want to remove, commit or abort?
> abort // Hu, what happened?
On branch "bugXY" // no MERGING any more???
Oops, what have I done? A repeated git merge
does not work, I have changed (and staged) files in my working directory now. OK, undo it. I tried:
> git reset --hard HEAD
and
> git checkout bugXY
Now nothing is staged any more, but I still have a bunch of untracked working tree files which hinder me to git merge
again ("would be overwritten, please [re]move them"). How can I do that? I guess rm path/to/file.php
for each of them would work, but there are a lot of them...