How to undo "git add". during the merger?

$ git checkout to-branch
$ git merge from-branch
$ git status | grep unmerged
#  file1    unmerged
#  file2    unmerged
#  file3    unmerged
$ vi file1
$ git add .

Ik! I did not want to "git add". I wanted to "git add file1"!

Now I can not get such behavior as:

$ git show :1:file2

I tried:

$ git reset file2

and

$ git checkout -m file2

but none of them returns file2 to the "unmerged" state. The git status does not display it as unmerged, and I do not have access to "git show: 1: file2", etc. I want to return the file to a state without interaction.

How can I get back to the state I was in before git add. "without losing my changes to file1?

+5
source share
2 answers

(Not tested) Have you tried

 git checkout -m /path/to/file2
 git checkout -m /path/to/file3

?

When checking paths from an index, this option allows you to recreate a conflicting merge on the specified paths.

, SO " git ?"

+10

- (, ), () :

git update-index --unresolve file2 file3
+1

All Articles