How to remove multiple deleted files in Git repository

git add -u 

updates all your changes


Be very cautious about git rm .; it might remove more than you want. Of course, you can recover, but it is simpler not to have to do so.

Simplest would be:

git rm modules/welcome/language/english/kaimonokago_lang.php \
       modules/welcome/language/french/kaimonokago_lang.php \
       modules/welcome/language/german/kaimonokago_lang.php \
       modules/welcome/language/norwegian/kaimonokago_lang.php

You can't use shell wildcards because the files don't exist, but you could use (in Bash at least):

git rm modules/welcome/language/{english,french,german,norwegian}/kaimonokago_lang.php

Or consider:

git status | sed -n '/^# *deleted:/s///p' | xargs git rm

This takes the output of git status, doesn't print anything by default (sed -n), but on lines that start # deleted:, it gets rid of the # and the deleted: and prints what is left; xargs gathers up the arguments and provides them to a git rm command. This works for any number of files regardless of similarity (or dissimilarity) in the names.

Tags:

Git

Git Rm