Search code examples
gitgit-resetgit-add

Unstage committed changes but keep new files in index


I want to split the last commit in two, so I use git reset HEAD~1, but then it loses track of the new files that were added by the commit (which were not tracked before), and I have to carefully add them back one by one. I often have other untracked files lying around waiting to be committed later, so this is annoying.

What I would like is a way to reset but keep the files added by the commit as empty, as if they had been added with git add --intent-to-add (i.e. git add -N).


Solution

  • After reading the doc more attentively, I found the answer.

    This does exactly what I want: git reset --mixed -N HEAD~1