Skip to content

Commit 693bd12

Browse files
committed
Add Untrack A File Without Deleting It as a git til.
1 parent 5abe41e commit 693bd12

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
7474
- [Staging Stashes Interactively](git/staging-stashes-interactively.md)
7575
- [Stashing Only Unstaged Changes](git/stashing-only-unstaged-changes.md)
7676
- [Stashing Untracked Files](git/stashing-untracked-files.md)
77+
- [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md)
7778
- [Verbose Commit Message](git/verbose-commit-message.md)
7879
- [Whitespace Warnings](git/whitespace-warnings.md)
7980

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Untrack A File Without Deleting It
2+
3+
Generally when I invoke `git rm <filename>`, I do so with the intention of
4+
removing a file from the project entirely. `git-rm` does exactly that,
5+
removing the file both from the index and from the working tree.
6+
7+
If you want to untrack a file (remove it from the index), but still have it
8+
available locally (in the working tree), then you are going to want to use
9+
the `--cached` flag.
10+
11+
```bash
12+
$ git rm --cached <filename>
13+
```
14+
15+
If you do this, you may also consider adding that file to the `.gitignore`
16+
file.
17+
18+
[source](http://stackoverflow.com/questions/15027873/untrack-and-stop-tracking-files-in-git)

0 commit comments

Comments
 (0)