Toontje
Toontje

Reputation: 1485

.gitignore not ignoring web.config

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?

Upvotes: 43

Views: 34002

Answers (3)

gravetii
gravetii

Reputation: 9624

git will not ignore a file that's already tracked before a rule is 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.

Upvotes: 70

Safi Habhab
Safi Habhab

Reputation: 1077

first make sure that the path of the web.config relative to the solution is correct

it could be for instance /Directory/Web.config

if you already made changes to web.config it won't be ignored unless you make the following:

  1. run this in cmd git rm --cached web.config to reset track.
  2. commit the web.config file that will be staged
  3. refresh git indexes in cmd git update-index --really-refresh

Upvotes: 0

Wille Esteche
Wille Esteche

Reputation: 1829

If the only you want to do is to prevent commits of web.config that you are running locally without affecting the one inchecked then run this command (in cmd or ps) under your project folder.

git update-index --assume-unchanged web.config

Upvotes: 20

Related Questions