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: project/war/index.html
Usually, i would stage them by issuing git add . command, but doing so does not affect git status. Files are still not staged for commit.
Now .. i know i can git rm file to take care of this.
The question is … can i modify git add . somehow to also stage deleted files as well? I thought add “.” takes care of everything (deleted files included)
git add .will add new and modified files to the index.git add -uwill 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:Addendum: It appears that the
-Aswitch will catch all three: added, modified, and deleted files.Note the extra ‘.’ on
git add -Aandgit add -uWarning, 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
See “Difference of “
git add -A” and “git add .”“.