Remove already tracked files with .gitignore

If you have already added a file to be tracked but now want it not to be you will need to add it to a .gitignore file in the root of your git repository then remove them from being tracked:

git rm --cached <file>

If you need to remove a whole folder and don’t want to list all the individual files you can use:

git rm -r --cached .

Then re add all files:

git add .

and commit your changes:

git commit -m "Added /folder to .gitignore"

source: http://stackoverflow.com/questions/1274057/making-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore

One thought on “Remove already tracked files with .gitignore”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s