From e416adc1ff51abecb14fd6ccd279661e41126c47 Mon Sep 17 00:00:00 2001 From: Samar Panda Date: Fri, 12 Feb 2016 23:56:56 +0530 Subject: [PATCH] Untrack files without deleting --- README.md | 12 ++++++++++++ tips.json | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 9a4d53d..557387b 100644 --- a/README.md +++ b/README.md @@ -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 git worktree add --detach HEAD ``` +## Untrack files without deleting +```sh +git rm --cached +``` + + +__Alternatives:__ +```sh +git rm --cached -r +``` + ## Before deleting untracked files/directory, do a dry run to get the list of these files/directories ```sh git clean -n diff --git a/tips.json b/tips.json index ff48dad..0e0d6be 100644 --- a/tips.json +++ b/tips.json @@ -144,6 +144,10 @@ }, { "title": "Create new working tree from HEAD state", "tip": "git worktree add --detach HEAD" +}, { + "title": "Untrack files without deleting", + "tip": "git rm --cached ", + "alternatives": ["git rm --cached -r "] }, { "title": "Before deleting untracked files/directory, do a dry run to get the list of these files/directories", "tip": "git clean -n"