From 20ca9a8e0c0bb1b80aa0747a1bc9d2488d0a8c41 Mon Sep 17 00:00:00 2001 From: Asocia Date: Wed, 30 Jun 2021 11:19:26 +0300 Subject: [PATCH] TIL: Removing a file without deleting it from disk --- git/removing-a-file-without-deleting-it-from-disk.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 git/removing-a-file-without-deleting-it-from-disk.md diff --git a/git/removing-a-file-without-deleting-it-from-disk.md b/git/removing-a-file-without-deleting-it-from-disk.md new file mode 100644 index 0000000..92dfdcd --- /dev/null +++ b/git/removing-a-file-without-deleting-it-from-disk.md @@ -0,0 +1,8 @@ +From Pro Git book: + +> Another useful thing you may want to do is to keep the file in your working tree but remove it from your staging area. In other words, you may want to keep the file on your hard drive but not have Git track it anymore. This is particularly useful if you forgot to add something to your .gitignore file and accidentally staged it, like a large log file or a bunch of .a compiled files. To do this, use the --cached option: +``` +git rm --cached README +``` + +