mirror of
https://github.com/tiimgreen/github-cheat-sheet.git
synced 2025-08-10 01:46:37 +02:00
Add 'Remove All Deleted Files from the Working Tree' command (see #104)
This commit is contained in:
28
README.md
28
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:
|
||||
|
||||
|
Reference in New Issue
Block a user