Skip to content

Commit e416adc

Browse files
committed
Untrack files without deleting
1 parent c42e154 commit e416adc

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
* [Show all ignored files](https://github.com/git-tips/tips#show-all-ignored-files)
5050
* [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)
5151
* [Create new working tree from HEAD state](https://github.com/git-tips/tips#create-new-working-tree-from-head-state)
52+
* [Untrack files without deleting](https://github.com/git-tips/tips#untrack-files-without-deleting)
5253
* [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)
5354
* [Forcefully remove untracked files](https://github.com/git-tips/tips#forcefully-remove-untracked-files)
5455
* [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>
369370
git worktree add --detach <path> HEAD
370371
```
371372

373+
## Untrack files without deleting
374+
```sh
375+
git rm --cached <file_path>
376+
```
377+
378+
379+
__Alternatives:__
380+
```sh
381+
git rm --cached -r <directory_path>
382+
```
383+
372384
## Before deleting untracked files/directory, do a dry run to get the list of these files/directories
373385
```sh
374386
git clean -n

tips.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@
144144
}, {
145145
"title": "Create new working tree from HEAD state",
146146
"tip": "git worktree add --detach <path> HEAD"
147+
}, {
148+
"title": "Untrack files without deleting",
149+
"tip": "git rm --cached <file_path>",
150+
"alternatives": ["git rm --cached -r <directory_path>"]
147151
}, {
148152
"title": "Before deleting untracked files/directory, do a dry run to get the list of these files/directories",
149153
"tip": "git clean -n"

0 commit comments

Comments
 (0)