4

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).

Lionel Parreaux
  • 1,115
  • 1
  • 9
  • 22

2 Answers2

4

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

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

Lionel Parreaux
  • 1,115
  • 1
  • 9
  • 22
1

Maybe I didn't understand very well, but isn't that a git reset --soft?

Mauricio Machado
  • 613
  • 1
  • 5
  • 14
  • Not really, as I want to make several new commits out of these changes, so I still want to selectively add things instead of have everything already staged. Hope this makes sense, sorry if it was unclear! – Lionel Parreaux Oct 30 '16 at 14:57
  • So, just a `git reset HEAD` unstages the changed files and then you can add them as you commit them. – Mauricio Machado Oct 31 '16 at 03:46
  • The whole point is that it loses track of new files (that were not tracked before the commit). I realize the term "added" is confusing in the context of git. I've made the question clearer. – Lionel Parreaux Oct 31 '16 at 10:51