git 中存储库特定的忽略文件
是否可以有特定于仓库的 .gitignore 文件?例如:
[来源] .gitignore:
- foo1.*
- foo2.*
[another] .gitignore:
- bar1.*
- bar2.*
其背后的目的是我们使用 git 部署到托管云服务上,并且我们希望将开发文件保留在版本控制中,但是不要将它们推送到仓库。
Is it possible to have repo specific .gitignore files? Eg:
[origin]
.gitignore:
- foo1.*
- foo2.*
[another] .gitignore:
- bar1.*
- bar2.*
The purpose behind this is that we deploy using git on to a managed cloud service and we'd like to keep dev files in version control but not push them to a repo.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,您可以将每个存储库忽略模式放入每个存储库的
.git/info/exclude
中。(请注意,这只会影响每个存储库中忽略的内容,不会影响您主动置于源代码控制和推送下的文件。我不完全清楚您想要的用例。)
Yes, you can put per repository ignore patterns in
.git/info/exclude
in each repository.(Note, this only affects what is ignored in each repository, it won't affect files that you actively place under source control and the push. I'm not completely clear on your desired use case.)
是的,可以,只是不能将它们放在同一个文件夹中。如果您创建一个新文件夹“deploy”并在那里发布部署数据,它将使用该文件夹(而不是根文件夹)中的 .gitignore。
Yes you can, just can't have them in the same folder. If you create a new folder, day "deploy" and publish your deploy data there, it will use the .gitignore in that folder (not the root one).
我的情况:
我的最终解决方案:
My Situation:
My final solution:
您可以使用 git hooks(.git 中的脚本)来完成此操作。结帐后听起来不错。
You could probably do this using git hooks (the scripts in .git). post-checkout sounds good.