How to modify git add to handle deleted files?

后端 未结 1 355
予麋鹿
予麋鹿 2021-01-30 17:08

I removed a few files from my git repo and now, upon status see

# Changes not staged for commit:
# ...
#   deleted:    project/war/favicon.ico
#   deleted:    pr         


        
相关标签:
1条回答
  • 2021-01-30 17:44

    git add . will add new and modified files to the index. git add -u will delete files from the index when they are deleted on-disk and update modified files, but will not add new files. You need a combination of the two:

    git add . && git add -u .
    

    Addendum: It appears that the -A switch will catch all three: added, modified, and deleted files.

    git add -A .
    

    Note the extra '.' on git add -A and git add -u


    Warning, starting git 2.0 (mid 2013), git add -A|u (not extra dot) will always stage files on the all working tree.
    If you want to stage file only under your current path with that working tree, then you need to use

    $ git add -A .
    

    See "Difference of “git add -A” and “git add .”".

    0 讨论(0)
提交回复
热议问题