git - 单个项目中的多个 .gitignore

标签 git gitignore

我在管理我正在开发的网站的 .gitignore 文件时遇到问题。我将我的网站存储在多个存储库中,这些存储库需要 stash 或从 git 中显示不同的文件。例如:我不希望我的 Github 存储库存储图像或数据库信息。另一方面,我的生产服务器需要查看这两个文件,但我可能不需要用于开发目的的某些文件。

管理多个存储库的 .gitignore 的最佳方法是什么?

最佳答案

.git/info/exclude 是仅限本地的 .gitignore

如果您将模式存储在那里,它将仅适用于该特定克隆。 .gitignore 但是,如果提交到存储库,则会同等影响所有存储库。

How do I tell git to ignore files?

.git/info/exclude is local to your repository only, and not shared by others who might fetch from your repository.
.gitignore is more commonly used, as it can be checked into the repository and thereby automatically shared with all users of the project.

关于git - 单个项目中的多个 .gitignore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11498512/

相关文章:

ruby-on-rails - 如何在不泄露应用程序 key 和凭据的情况下开源我的 Rails 应用程序

visual-studio - 为 Visual Studio Xamarin 项目推荐的 .gitignore 文件

git - 如何以不被跟踪的方式将文件存储在 GIT 中?

git - 如何在初始提交时使用 git format-patch

git - 如何使用 git 正确处理 GreaseMonkey 用户脚本?

git - 在没有读取权限的情况下忽略 git 子模块

git - .gitignore 中的异常

Git 列表按 Blob 提交

git - 如何备份git服务器?

Git - 如何递归地忽略一个目录中的所有文件,但一些具有特定扩展名的文件