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

后端 未结 5 475
不知归路
不知归路 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:23

    There's also a very similar approach making use of the --cached flag...

    1) Turn your unstaged changes into staged, just like your added file.

    git add edited-file.txt
    git add new-file.txt
    git add directory-of-changes/
    

    2) Look at the diff (note: you can include both edits and new files).

    git diff --cached
    

    3) Create the patch.

    git diff --cached > my_patch_file.patch
    

提交回复
热议问题