git .gitignore 不忽略 web.config
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22038600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.gitignore not ignoring web.config
提问by Toontje
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.
对于我的远程存储库,我试图忽略我的 Umbraco 网站的 web.config 文件。.gitignore 位于我网站的根目录中,要忽略的文件 web.config 也在我网站的根目录中。
so I added this line to my .gitignore file:
所以我将此行添加到我的 .gitignore 文件中:
web.config
But everytime I push changes to my remote repository, the web.config file is also pushed to the remote repository.
但是每次我将更改推送到我的远程存储库时,web.config 文件也会被推送到远程存储库。
What am I doing wrong?
我究竟做错了什么?
回答by gravetii
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>
.
git 不会忽略在将规则添加到此文件以忽略它之前已经跟踪的文件。在这种情况下,必须使用git rm --cached <filename>
.
So if you are trying to ignore this file newly, run this: git rm --cached web.config
.
所以,如果你正在尝试新忽略此文件,运行以下命令:git rm --cached web.config
。
回答by Wille Esteche
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.
如果您只想阻止提交您在本地运行的 web.config 而不会影响已检查的,那么在您的项目文件夹下运行此命令(在 cmd 或 ps 中)。
git update-index --assume-unchanged web.config