If you have a file that's unknown to git (ie., it appears in the
"untracked" section of git status
), and you want to add only part of
the file to the index, git won't allow it: No changes.
Instead, mark the file for adding, but without adding any actual line:
$ git add -N file
$ git add -p file
-N
is short for --intent-to-add
and does just that: Create an
index entry with an empty content field.