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?
Asked
Active
Viewed 3,746 times
13
-
As a comment because it's no proper answer: I often use `git citool`. There, you can interactively pick what to commit (including deletions). – Tilman Vogel Jun 07 '11 at 08:14
-
1This is essentially a duplicate of at least these three questions: http://stackoverflow.com/q/6090732/223092 http://stackoverflow.com/q/492558/223092 http://stackoverflow.com/q/3169787/223092 – Mark Longair Jun 07 '11 at 08:20
2 Answers
19
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)

Sven Marnach
- 574,206
- 118
- 941
- 841
-
@SvenMarnach Will the removed files be visible if I move the head to a previous commit point or are they totally gone? – user137717 Feb 05 '15 at 01:38
-
1@user137717: If the files are committed in an earlier commit, they will still be there. This command only removes the files that have been deleted from the working directory from the staging area as well. – Sven Marnach Feb 05 '15 at 14:48
5
git add -A
will add all changes, including deletions, to the index. Then commit away.

James Gregory
- 14,173
- 2
- 42
- 60