diff --git a/README.md b/README.md index 7c59c59..c8a57ce 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Staging Stashes Interactively](git/staging-stashes-interactively.md) - [Stashing Only Unstaged Changes](git/stashing-only-unstaged-changes.md) - [Stashing Untracked Files](git/stashing-untracked-files.md) +- [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md) - [Verbose Commit Message](git/verbose-commit-message.md) - [Whitespace Warnings](git/whitespace-warnings.md) diff --git a/git/untrack-a-file-without-deleting-it.md b/git/untrack-a-file-without-deleting-it.md new file mode 100644 index 0000000..ab0d658 --- /dev/null +++ b/git/untrack-a-file-without-deleting-it.md @@ -0,0 +1,18 @@ +# Untrack A File Without Deleting It + +Generally when I invoke `git rm `, I do so with the intention of +removing a file from the project entirely. `git-rm` does exactly that, +removing the file both from the index and from the working tree. + +If you want to untrack a file (remove it from the index), but still have it +available locally (in the working tree), then you are going to want to use +the `--cached` flag. + +```bash +$ git rm --cached +``` + +If you do this, you may also consider adding that file to the `.gitignore` +file. + +[source](http://stackoverflow.com/questions/15027873/untrack-and-stop-tracking-files-in-git)