我想忽略分支中的某些文件,而不必依赖于跟踪.gitignore
在与其他分支合并期间将被覆盖的文件。
我一直密切关注堆栈溢出答案随着链接的博客文章,但我的存储库似乎无法识别指定的excludesfile
in my .git/config
。 Git 文档(git-config, gitignore)似乎没有显示如何指定和解决特定分支的排除文件。
My .git/config
看起来像这样:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
excludesfile = +/info/exclude
[branch "myspecialbranch"]
excludesfile = +/info/exclude_specialbranch
My .git/info/exclude
文件看起来像这样(默认情况下,我没有碰它):
# 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]
# *~
.DS_Store
我没有.gitignore
文件在我的“特殊分支”中。
如果我尝试忽略像这样的文件info.php
, my .git/info/exclude_specialbranch
文件看起来像这样:
info.php
...但它不会忽略该文件。
如果我跑git status --ignored
,它只列出了.DS_Store
文件从默认exclude
file.
但是,如果我添加info.php
to my .git/info/exclude
file:
# 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]
# *~
.DS_Store
info.php
它完全忽略该文件。
请注意,即使没有这条线,它仍然可以工作excludesfile = +/info/exclude
under [core]
in .git/config
。 Git 似乎知道系统范围在哪里exclude
无需我去讲述。
我有一种感觉.git/config
无法识别我的自定义排除文件的地址:
excludesfile = +/info/exclude_specialbranch
…很可能是因为使用+
来描述该位置.git
目录。
在(更新的)版本的 Git 中处理自定义排除文件的正确方法是什么?
我运行的是 OSX 10.9.5 和 Git 版本 2.2.1。