Hacker News new | past | comments | ask | show | jobs | submit login

It can, you just gotta do a magic incantation first.

  git add -N file
  git add -p file
The first command signals to git that you intend to add the file. That makes its entire content show up in the patch editor.



TIL! I seem to have just missed the `-N`/`--intend-to-add` while perusing through the `git-add(1)` manual.

Heh, it[0] even notes a similar use case:

> `-N` > `--intent-to-add` > > Record only the fact that the path will be added later. An entry for the path is placed in the index with no content. This is useful for, among other things, showing the unstaged content of such files with `git diff` and committing them with `git commit -a`.

[0]: <https://git-scm.com/docs/git-add#Documentation/git-add.txt--...>




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: