Quick Hits: When your .gitignore file gets…ignored
Posted: February 6th, 2010 | Author: abel | Filed under: Version Control | Tags: GIT, noob | 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:
- Keep your .gitignore file.
- 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 . - Add everything in your project. Your .gitignore file will exclude what you want to ignore now and start tracking the good stuff.
git add . - Commit your changes.
git commit -m "Now my .gitignore file works correctly!"
Happy codding!