Remove previously tracked file from git repository

Here’s a simple git command that will remove a previously tracked file from a git repository:

git rm --cached <file>

The file will be removed from the head on the next commit.

I run into this issue often when using Tower to manage repositories. There doesn’t seem to be an easy way to remove items I’d forgotten to add to .gitignore.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Check out our Complete Website Package

Chat with us about your project or click below to find out more!

Learn More   Chat with us

Hi. We are Spigot. Telemarketers pronounce it Spy-got.

We are a Park City, Utah based web design shop that excels at building custom websites powered by WordPress and WooCommerce. We love content - content strategy, content curation, content soup...????Have a look around the site. As you browse you'll find useful navigation links in the sidebar on the left. We hope you find them useful anyway... Please let us know what you think, shoot us a message here.