[英]How to ignore files with git - without adding to .gitignore
I think that the answer to this question is probably that it can't be done but I would be interested to hear any solutions or workarounds that people use. 我认为该问题的答案可能是无法解决,但是我很想听听人们使用的任何解决方案或解决方法。
The situation is that I have a seed npm project. 情况是我有一个种子npm项目。 Whenever my team wants to start a new project they clone this project and use it as a basis for the new work.
每当我的团队想要开始一个新项目时,他们都会克隆该项目并将其用作新工作的基础。
In this seed project when I do npm install
I get a package-lock.json
file. 在这个种子项目中,当我执行
npm install
我得到一个package-lock.json
文件。 I do not want to check this file in as I do not want to lock projects that are based on the seed project to the dependency versions of the seed project. 我不想签入此文件,因为我不想将基于种子项目的项目锁定到种子项目的依赖版本。
However, I do not want to add this file to the .gitignore
file as if I do that the .gitignore
file would also be copied and then the lock file would also be ignored in the project that is based on the seed. 但是,我不想将此文件添加到
.gitignore
文件中,就好像我也会复制.gitignore
文件,然后在基于种子的项目中也将忽略锁定文件一样。
I hope that I have explained that well enough. 我希望我已经解释得足够好了。
You can create local ignore rules that are not shared as part of the repository content. 您可以创建不作为存储库内容一部分共享的本地忽略规则。 Of course each clone that needs the rule has to be configured individually, but for your use case that's probably a good trade-off.
当然,每个需要规则的克隆都必须单独配置,但是对于您的用例来说,这可能是一个很好的折衷方案。
The file .git/info/exlcude
works just like .gitignore
but is loacl. 文件
.git/info/exlcude
工作方式与.gitignore
但很差。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.