From 6b9a6eb39d407982587155ed60b387a25650d123 Mon Sep 17 00:00:00 2001 From: Imri Paloja Date: Wed, 28 Sep 2022 17:34:05 +0200 Subject: [PATCH 1/3] Update 'README.md' --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 67ae53c..44a14fa 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,24 @@ git push -u origin main git remote add origin https://git.eurobytes.eu/imri/Test.git git push -u origin main ``` + +# How do I make Git forget about a file that was tracked, but is now in .gitignore? + +First: + +```bash +git rm -r --cached . +git add . +``` + +Then: + +```bash +git commit -am "Remove ignored files" +``` + +Or as a one-liner: + +```bash +git rm -r --cached . && git add . && git commit -am "Remove ignored files" +``` \ No newline at end of file -- 2.54.0 From 1c173592b28908f9df12588a18faa398238db7ed Mon Sep 17 00:00:00 2001 From: Imri Paloja Date: Mon, 3 Oct 2022 21:56:21 +0200 Subject: [PATCH 2/3] Update 'README.md' --- README.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 44a14fa..8f41230 100644 --- a/README.md +++ b/README.md @@ -33,24 +33,26 @@ git push -u origin main git remote add origin https://git.eurobytes.eu/imri/Test.git git push -u origin main ``` - # How do I make Git forget about a file that was tracked, but is now in .gitignore? -First: +`.gitignore` will prevent untracked files from being added (without an `add -f`) to the set of files tracked by Git. However, Git will continue to track any files that are already being tracked. -```bash -git rm -r --cached . -git add . -``` +To stop tracking a file, we must remove it from the index: + + git rm --cached + +To remove a folder and all files in the folder recursively: + + git rm -r --cached + +The removal of the file from the head revision will happen on the next commit. + +**WARNING: While this will not remove the physical file from your local machine, it will remove the files from other developers' machines on their next `git pull`.** + +https://stackoverflow.com/a/1274447/1148529 + +# Further git info -Then: -```bash -git commit -am "Remove ignored files" -``` -Or as a one-liner: -```bash -git rm -r --cached . && git add . && git commit -am "Remove ignored files" -``` \ No newline at end of file -- 2.54.0 From 475b75d2a9c477a55f1d958a266fad49f6fecb49 Mon Sep 17 00:00:00 2001 From: Imri Paloja Date: Thu, 13 Oct 2022 20:36:30 +0200 Subject: [PATCH 3/3] Update 'README.md' --- README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8f41230..1d80dfa 100644 --- a/README.md +++ b/README.md @@ -35,21 +35,27 @@ git push -u origin main ``` # How do I make Git forget about a file that was tracked, but is now in .gitignore? -`.gitignore` will prevent untracked files from being added (without an `add -f`) to the set of files tracked by Git. However, Git will continue to track any files that are already being tracked. -To stop tracking a file, we must remove it from the index: +The series of commands below will remove all of the items from the Git index (not from the working directory or local repository), and then will update the Git index, while respecting Git ignores. *PS. Index = Cache* - git rm --cached +**First:** -To remove a folder and all files in the folder recursively: + git rm -r --cached . + git add . - git rm -r --cached +**Then:** -The removal of the file from the head revision will happen on the next commit. + git commit -am "Remove ignored files" -**WARNING: While this will not remove the physical file from your local machine, it will remove the files from other developers' machines on their next `git pull`.** +--- -https://stackoverflow.com/a/1274447/1148529 +Or as a one-liner: + +```git +git rm -r --cached . && git add . && git commit -am "Remove ignored files" +``` + +https://stackoverflow.com/a/19095988 # Further git info -- 2.54.0