What you expect it to do
Normally, you expect .gitignore to keep files from uploading to your repository, and it is, of course, especially useful for holding on to local configuration files.
When it fails
In some instances, I’ve ignored a file, but it continues to attempt to push to my repository – most likely because I have one previous commit with the file not ignored. Sometimes, though, it seems to happen even when I’ve made sure to ignore the file immediately after cloning from origin; this seems to happen to me only when using Eclipse Git, so it may be a bug, or may just be me not doing things in the right order. In any case, I found a handy way to refresh the .gitignore and force it to take on Stack Oveflow.
You basically pull everything from the staging area, and then add them all again, and commit.
Make sure to commit before you do it, or you’ll lose any changes you’ve made before you do this.
git commit -m "my commit message"git rm -r --cached .
This removes everything from the index. Then, add files back into staging, and .gitignore
git add .
git commit -m ".gitignore is now working"
And that’s it.
But those config files
When you pull from origin, you may be asked to merge those config files, even though they are ignored. In that case, use .gitattributes