Sit back, relax, and enjoy the code.

Quick Hits: When your .gitignore file gets…ignored

Posted: February 6th, 2010 | Author: abel | Filed under: Version Control | Tags: , | No Comments »

I made a mistake while creating a GIT repos that I’m hoping I can save you from making.  I made my first commit on a project and I realized that a bunch of files were getting in that shouldn’t be.  I created a .gitignore file, but the issue kept happening on subsequent commits.  As I learned later, you SHOULD create your .gitignore file first.  However, if you forgot, this is how you fix it:

  1. Keep your .gitignore file.
  2. Clear your GIT cache.  Don’t worry, this won’t delete any of your local files, just what GIT is tracking.
    git rm -r --cached .
  3. Add everything in your project.  Your .gitignore file will exclude what you want to ignore now and start tracking the good stuff.
    git add .
  4. Commit your changes.
    git commit -m "Now my .gitignore file works correctly!"

Happy codding!

  • Share/Bookmark