Answered by : brave-bear-559060p1sbxx
# Remove the files from the index (not the actual files in the working copy)
$ git rm -r --cached .
# Add these removals to the Staging Area...
$ git add .
# ...and commit them!
$ git commit -m "Clean up ignored files"
Source : https://www.git-tower.com/learn/git/faq/ignore-tracked-files-in-git | Last Update : Fri, 10 Dec 21
Answered by : clment-combier
# First solution
$ git rm -r --cached . # We remove
$ git add . # We stage
$ git commit -m "Clean up ignored files" # We commit
# Second solution : if you have a lot of files
# It's basicaly the first solution in one line
git rm --cached `git ls-files -i -c --exclude-from=.gitignore`
# If you are on Windows and the line above didn't work, try this one in Powershell
git ls-files -i -c --exclude-from=.gitignore | %{git rm --cached $_}
Source : | Last Update : Sun, 27 Feb 22
Answered by : perfect-peacock-suu2349dxzwe
git rm -r --cached . && git add . && git commit -am "Remove ignored files"
Source : https://stackoverflow.com/questions/1274057/how-can-i-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitign | Last Update : Thu, 04 Nov 21
Answered by : ab498
# remove from local indexing
git rm -r --cached .
# remove actual files from remote repo
git add .
git commit -am "Remove ignored files"
git push -f origin main
Source : | Last Update : Mon, 09 Jan 23
Answered by : annoyed-armadillo-68vzzg83ww9f
git rm -r --cached .
git add .
git commit -am "Drop ignored files"
Source : https://stackoverflow.com/questions/39061898/git-gui-ignores-gitignore-file | Last Update : Tue, 30 Aug 22
Answered by : dennis-muensterer-10gav4t7fjtq
git rm --cached <file>
git rm -r --cached <folder>
Source : https://stackoverflow.com/questions/1274057/how-can-i-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitign | Last Update : Tue, 21 Sep 21
Answered by : hurt-hummingbird-z8ayer93g4uh
git ls-files --ignored --exclude-standard -z | xargs -0 git rm --cached
git commit -am "Remove ignored files"
// answer from: thSoft
Source : https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore | Last Update : Fri, 03 Jul 20
Answered by : plain-piranha
git rm -r --cached .
git add .
git commit -m "Removes all .gitignore files and folders"
Source : https://www.baeldung.com/git-remove-tracked-files-gitignore | Last Update : Sun, 29 Oct 23
Answered by : joseph-charika
{"tags":[{"tag":"textarea","content":"git rm -r --cached . && git add . && git commit -am \"Remove ignored files\"","code_language":"shell"}]}
Source : | Last Update : Sun, 05 Feb 23