Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

How can I ignore files that have already been committed to the repo?

Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a .gitignore file with all the file patterns you want to ignore.

However, of course, not everything goes perfect... and files slip through that you later would like to see ignored.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Preparing the Cleanup

Before cleaning up your repository, you should conduct two important preparations:

  1. Make sure your .gitignore file is up-to-date and contains all the correct patterns you want to ignore.
  2. Commit or stash any outstanding local changes you might have. Your working copy should be clean before you continue.
Tip

How to Ignore Files

Our free online book explains the general process of how to ignore files in great detail.

Cleaning Ignored Files

In three steps, you can clean up your repository and make sure your ignored items are indeed ignored:

# 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"


Tip

Ignoring Committed Files in Tower

In case you are using the Tower Git client, the app does the heavy lifting for you: when trying to ignore a file that is already tracked in Git, Tower will ask if you want to untrack it - so that the ignore rules can do their work.


Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.