Question:
When I run git add -p
, is there a way for git to select newly made files as hunks to select??
So if I make a new file called foo.java
, then run git add -p, git will not let me choose that file’s content to be added into the index.
Answer:
To include every new files, you can run:
1 2 3 |
git add -N . git add -p |
If you want to use it frequently, you can create an alias in your ~/.bashrc
:
1 2 |
alias gapan='git add --intent-to-add . && git add --patch' |
N.B: If you use this with an empty new file, git will not be able to patch it and skip to the next one.