Written by Sean Behan on Sun Jun 17th 2012

To remove files that are currently being tracked by git, you have to remove them from the "cache". Note, doing this will NOT delete the file on your local machine. It will still be there but not be tracked.

 git rm -r --cached supersecretpasswords.txt 
You then need to add the file to the .gitignore file in the root of the project so that it isn't tracked again on your next commit.

vim .gitignore supersecretpasswords.txt

.gitignore files are tracked so remember to check in these changes.
git commit -am'my super secret passwords are safe!'

If you want to completely delete the file, on your local machine and from git

git rm supersecretpasswords.txt
If you're working with a directory remember to add the -r flag for recursive removal!

Tagged with..
#development #Git #gitignore #productivity #rm #source control #workflow #Git

Just finishing up brewing up some fresh ground comments...