Un-track files in git

Recently I realized I wanted to un-track a few files in one of my git repositories for a drupal 6 site. These were files that weren’t portable between the prod, staging and dev servers.
One example would be the drushrc file. Aegir creates this file and it contains info specific to the server the site is on.
So I went looking for a way to un-track but keep the file.
I learned from experience that ‘git rm’ (the remove command) is not quite right, but if you add ‘–cached’ to the command you’re all set.

So, if you have a file being tracked by git and you want to get rid of it you can use this command

git rm --cached file/name

Ref: http://source.kohlerville.com/2009/02/untrack-files-in-git/

In addition, you should add the file to your .gitignore document.

Now when you run,

git status


git commit

the offending file wont be included.