Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle a bunch of deleted files under Git?

Tags:

git

I have deleted about 20 files from my project. How to commit them with one command instead of git rm <filename> them one by one?

like image 620
Leem Avatar asked Jun 07 '11 07:06

Leem


People also ask

What to do when git deleted files?

If you have deleted the file and already committed the changes, you need to use the ` git checkout` command to restore the file. First, you need to find out the checksum of the commit that deleted the file, and then check out the file from the previous commit.

Does git remove deleted files?

By default, the git rm command deletes files both from the Git repository as well as the filesystem. Using the --cached flag, the actual file on disk will not be deleted.

How do I rm multiple files in git?

OPTIONS. Files to remove. A leading directory name (e.g. dir to remove dir/file1 and dir/file2 ) can be given to remove all files in the directory, and recursively all sub-directories, but this requires the -r option to be explicitly given. The command removes only the paths that are known to Git.


1 Answers

If you don't want to commit all other changes in your working directory at the same time (as git add -A would do), you can use

git rm $(git ls-files --deleted)
like image 183
Sven Marnach Avatar answered Oct 04 '22 00:10

Sven Marnach