Remove all deleted files from “changed but not updated” in Git

后端 未结 3 1736
萌比男神i
萌比男神i 2020-12-07 23:16

When I run git status, I have a bunch of lines of the form

deleted:    dir/file.js

I can remove each of these individually wit

相关标签:
3条回答
  • 2020-12-07 23:38

    You can still git rm after the fact, but if you want, you can restore all your changed files (including deletions) to the last revision with git reset --hard

    0 讨论(0)
  • 2020-12-07 23:40

    As rampion points out, you can still use git rm to stage the deletion of files that have already been deleted in your working copy (e.g. just git rm dir/file.js in your case.) If you have a lot of these files listed as "deleted:" under "Changed but not updated", I would first check that git ls-files --deleted produces a list of these files, and, if so, delete them with:

    git ls-files --deleted -z | xargs -0 git rm
    
    0 讨论(0)
  • 2020-12-07 23:44

    So, do you want to commit the deletion of those files? Then use

    git add -u
    git commit
    
    0 讨论(0)
提交回复
热议问题