Git: How to automatically stage deleted files for commit

Updated . Posted . Visible to the public.

When you do a git add . and have deleted files, git won’t stage them to be commited (as deleted). Use

git add -u

From the git documentation: -u, --update <filepattern>

Only match against already tracked files in the index rather than the working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.
If no is given, default to "."; in other words, update all tracked files in the current directory and its subdirectories.

Dominik Schöler
Last edit
Dominik Schöler
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2011-05-30 15:47)