.gitignore not working in github for mac program

Nathan B picture Nathan B · Jan 22, 2013 · Viewed 7.2k times · Source

I searched around and found some tutorials explaining out to fix the problem, unfortunately they haven't worked.

Basically what's happening is I have files in the .gitignore that the github for mac program I'm using is trying to commit, despite them being ignored. I found some blogs and even other posts on stackoverflow saying that you can fix it with the command line, and giving explanations how. Unfortunately I have absolutely no experience with the command line and my attempts to follow their directions have all failed to solve the problem.

Is there a way to fix this problem without using the command line? and if not can someone tell me how to use the command line hack found here among other places:

git rm -r --cached .
git add .
git commit -m "fixing .gitignore"

Answer

Lily Ballard picture Lily Ballard · Jan 22, 2013

Are these files already tracked, and GitHub for Mac is trying to commit the modifications? .gitignore only prevents untracked files from being added/committed by git. Once a file has become tracked, .gitignore stops being consulted.

The "hack" you linked is really just asking git to delete all of the files in the repo, then re-adding it all back. This works because the .gitignore will be consulted when re-adding files (because it's consulted for any files not already in the index, and the git rm -r --cached . deleted the entire index).