'git add --patch' to include new files?

后端 未结 5 699
不知归路
不知归路 2021-01-29 22:39

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

5条回答
  •  感动是毒
    2021-01-29 23:16

    To do this with every new files, you can run:

    git add -N . # Add every untracked file in $PWD without their content.
    git add -p   # Interactively add content.
    

    If you want to use it frequently, you can create an alias in your ~/.bashrc:

    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.

提交回复
热议问题