将 .gitignore 添加到存储库的最佳实践

发布于 2024-11-19 03:32:37 字数 84 浏览 3 评论 0原文

关于 Git 的 .gitignore 文件的最佳实践是什么?应该将其从存储库中排除还是包含在内?如果是有条件的,每种情况的条件是什么?

What is the best practice regarding the .gitignore file with Git; should it be excluded from the repository or included? If it's conditional, what are the conditions for each circumstance?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

澉约 2024-11-26 03:32:37

它们几乎总是应该被包含在内,因为它们的目的是忽略“输出”文件(编译的二进制文件、日志文件),这些文件将由任何使用项目克隆的人生成。它们应该受到版本控制并包含在存储库中。

您不应使用存储库中的 .gitignore 文件来忽略只为您显示的文件,例如特定于编辑器的交换文件。您应该将这些规则放在 全局 .gitignore 文件 中,以便它们适用于所有存储库,或在 .git/info/excludes 中。

They should almost always be included, as their purpose is to ignore "output" files (compiled binaries, log files) which are going to be generated by anybody working with a clone of your project. They're meant to be version-controlled and included with the repository.

You should not use .gitignore files within the repository to ignore files that only appear for you, such as editor-specific swap files. You should be placing those rules in a global .gitignore file so that they apply to all repositories, or in .git/info/excludes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文