Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore not ignoring web.config

Tags:

git

umbraco

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?

like image 702
Toontje Avatar asked Feb 26 '14 10:02

Toontje


People also ask

Why is my Gitignore not ignoring?

gitignore only ignores files that are not part of the repository yet. If you already git add ed some files, their changes will still be tracked. To remove those files from your repository (but not from your file system) use git rm --cached on them. git rm --cached file_name.

How do I ignore a .gitignore file?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.


1 Answers

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.

like image 114
gravetii Avatar answered Sep 18 '22 19:09

gravetii