git .gitignore 不忽略 package.json
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31660687/
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 package.json
提问by cheddarDev
I have a node project and I am trying to ignore my package.json.
我有一个节点项目,我试图忽略我的 package.json。
I have added package.json inside .gitignore.
我在 .gitignore 中添加了 package.json。
Basically I am working on creating swimlanes and I have another project's package.json overwritting the existing project's package.json.
基本上我正在创建泳道,并且我有另一个项目的 package.json 覆盖了现有项目的 package.json。
What i see happening is the package.json file is overwritting the existing and its not ignoring the new package.json althought its in the .gitignore.
我看到的情况是 package.json 文件覆盖了现有的并且它没有忽略新的 package.json 尽管它在 .gitignore 中。
I tried
我试过
git rm --cached
and
和
git add .
But this is deleteing my package.json file from my local which I dont want
但这是从我不想要的本地删除我的 package.json 文件
Expected: I need the package.json to be igniored when I pull the new package.json using grunt fetchFromArtifactory.
预期:当我使用 grunt fetchFromArtifactory 提取新的 package.json 时,我需要忽略 package.json。
回答by Larry Shatzer
If you already are tracking a file, you can't add it to .gitignore
. Then git will start to track that file changes.
如果您已经在跟踪文件,则无法将其添加到.gitignore
. 然后 git 将开始跟踪该文件更改。
You can look at this answerto how to tell git to ignore changes in a tracked file.
您可以查看有关如何告诉 git 忽略被跟踪文件中的更改的答案。