Committing file deletes to Git

My normal git usage pattern is:

git add .
git commit -m "commit message"

and then when needed:

git push remotename master

The trouble with ‘git add .’ is that is doesn’t stage any deleted files for committing. You can see this if you do a ‘git status’ and you’ll see it list deleted files, but listed as not staged:

$git status
# On branch master
# Changes not staged for commit:
#  (use "git add/rm " to update what will be committed)
# deleted: ...

You’ll notice the comment mentions to use ‘git rm’ to delete files from the repo, but if you’ve deleted files locally, you can either do a ‘git rm filename’ for each of the locally deleted files, or more simply, do this to pick up all changed files for staging, including deletes:

git add -A

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.