2011-03-11 46 views
32
$ cat ~/.gitconfig 
[core] 
     editor = vim 
     excludefiles = /home/augustin/.gitignore 
$ cat ~/.gitignore 
toto 
$ mkdir git_test 
$ cd git_test/ 
$ git init 
$ touch toto 
$ git status 

# On branch master 
# 
# Initial commit 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
#  toto 
nothing added to commit but untracked files present (use "git add" to track) 
$ git --version 
git version 1.6.3.3 

爲什麼toto不被忽略?爲什麼我的全局.gitignore文件忽略?

〜/ .gitconfig中的其他設置會被考慮在內(顏色,編輯器)。

+0

'git config --global core.excludesfile〜/ .gitignore'。找到它[這裏](http://crucial-systems.com/global_gitignore),目前無法測試它 – ierax 2011-03-11 09:21:19

+0

@faif:那有效。提交這個答案,以便我可以接受它。謝謝。 – augustin 2011-03-11 09:31:28

+0

我做到了。也謝謝你:) – ierax 2011-03-11 09:56:22

回答

79

git config --global core.excludesfile ~/.gitignore

+8

我已經檢查過並檢查了任何錯字,但是我的原始問題在變量設置名稱中歸結爲缺少's'。在應用您的解決方案後檢查配置文件後,我意識到了這個問題。謝謝。 – augustin 2011-03-11 09:58:49

+0

啊。打字錯誤。那就是問題所在。謝謝! – Vegar 2012-03-27 22:42:12

+0

我注意到,如果您在命令中使用〜/或$ HOME /,它會擴展到/ Users/USER /。不知道這是否也是我的問題。 – 2013-12-31 21:33:52