我想要自动排除两个文件的提交,它们是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
呢? - maverikexclude
不起作用,.gitignore
也不会。使用exclude
的情况是此信息仅在本地,而.gitignore
可以被检入并共享。当您不想扩大.gitignore
文件时,使用exclude
来处理本地内容。想象一下一个大型项目,在其中每个开发人员都将他的排除项输入到.gitignore
中。这将变得难以管理... - eckes