【发布时间】:2012-06-04 10:24:16
【问题描述】:
我想从提交中自动排除 2 个文件,它们是 git 存储库的一部分,但有一些更改,不应该是 github 存储库的一部分,因为它们有一些仅对我的本地系统有意义的更改和而不是其他开发者。
我将它们添加到 .git/info/exclude,希望 git 明白他不应该对它们进行更改:
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
a.conf
b.conf
# *~
但git status 仍将它们列为已提交:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: build/conf/a.conf
# modified: build/conf/b.conf
#
我不想在每次提交时定期取消暂存它们(有一次我可能会忘记),我该怎么做?
【问题讨论】:
-
为什么不
.gitignore? -
您不能忽略正在跟踪的文件。您可能需要找到另一种管理本地系统特定信息的方法,例如拥有“模板”文件,您可以从中生成或手动编辑配置文件。
-
@maverik:如果
exclude不起作用,.gitignore也不会。exclude的用例是此信息在本地,而.gitignore可以签入和共享。当您不想炸毁.gitignore时,请使用exclude获取本地内容。想象一个大型项目,每个开发人员都将他的排除项输入到.gitignore。它将变得无法管理......