Untrack files without deleting

This commit is contained in:
Samar Panda 2016-02-12 23:56:56 +05:30
parent c42e1547ab
commit e416adc1ff
2 changed files with 16 additions and 0 deletions

View File

@ -49,6 +49,7 @@
* [Show all ignored files](https://github.com/git-tips/tips#show-all-ignored-files)
* [Create new working tree from a repository (git 2.5)](https://github.com/git-tips/tips#create-new-working-tree-from-a-repository-git-25)
* [Create new working tree from HEAD state](https://github.com/git-tips/tips#create-new-working-tree-from-head-state)
* [Untrack files without deleting](https://github.com/git-tips/tips#untrack-files-without-deleting)
* [Before deleting untracked files/directory, do a dry run to get the list of these files/directories](https://github.com/git-tips/tips#before-deleting-untracked-filesdirectory-do-a-dry-run-to-get-the-list-of-these-filesdirectories)
* [Forcefully remove untracked files](https://github.com/git-tips/tips#forcefully-remove-untracked-files)
* [Forcefully remove untracked directory](https://github.com/git-tips/tips#forcefully-remove-untracked-directory)
@ -369,6 +370,17 @@ git worktree add -b <branch-name> <path> <start-point>
git worktree add --detach <path> HEAD
```
## Untrack files without deleting
```sh
git rm --cached <file_path>
```
__Alternatives:__
```sh
git rm --cached -r <directory_path>
```
## Before deleting untracked files/directory, do a dry run to get the list of these files/directories
```sh
git clean -n

View File

@ -144,6 +144,10 @@
}, {
"title": "Create new working tree from HEAD state",
"tip": "git worktree add --detach <path> HEAD"
}, {
"title": "Untrack files without deleting",
"tip": "git rm --cached <file_path>",
"alternatives": ["git rm --cached -r <directory_path>"]
}, {
"title": "Before deleting untracked files/directory, do a dry run to get the list of these files/directories",
"tip": "git clean -n"