.gitignore not ignoring web.config

Toontje picture Toontje · Feb 26, 2014 · Viewed 22.1k times · Source

For my remote repository, I'm trying to ignore the web.config file of my Umbraco website. The .gitignore is in the root of my website, and the file to ignore, web.config is also in the root of my website.

so I added this line to my .gitignore file:

web.config

But everytime I push changes to my remote repository, the web.config file is also pushed to the remote repository.

What am I doing wrong?

Answer

gravetii picture gravetii · Feb 26, 2014

git will not ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked with git rm --cached <filename>.

So if you are trying to ignore this file newly, run this: git rm --cached web.config.