From 53e3a65c73be3b96ce3df4dfb7f507d1239165ae Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Wed, 18 Feb 2015 22:04:12 +0000 Subject: [PATCH] Add 'Remove All Deleted Files from the Working Tree' command (see #104) --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index ee97912..9da0195 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ A collection of cool hidden and not so hidden features of Git and GitHub. This c - [GitHub Resources](#github-resources) - [GitHub Talks](#github-talks) - [Git](#git) + - [Remove All Deleted Files from the Working Tree](#remove-all-deleted-files-from-the-working-tree) - [Previous Branch](#previous-branch) - [Stripspace](#stripspace) - [Checking out Pull Requests](#checking-out-pull-requests) @@ -578,6 +579,33 @@ GitHubs icons (Octicons) have now been open sourced. | More Git and GitHub Secrets | https://www.youtube.com/watch?v=p50xsL-iVgU | ## Git +### Remove All Deleted Files from the Working Tree +When you delete a lot of files using `/bin/rm` you can use the following command to remove them from the working tree and from the index, eliminating the need to remove each one individually: + +```bash +$ git rm $(git ls-files -d) +``` + +For example: + +```bash +$ git status +On branch master +Changes not staged for commit: + deleted: a + deleted: c + +$ git rm $(git ls-files -d) +rm 'a' +rm 'c' + +$ git status +On branch master +Changes to be committed: + deleted: a + deleted: c +``` + ### Previous Branch To move to the previous branch in Git: