Why doesn't my global .gitignore file ignore?

一笑奈何 提交于 2019-12-03 01:55:15

问题


$ 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

Why isn't toto being ignored?

Other settings in ~/.gitconfig are taken into account (colors, editor).


回答1:


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




回答2:


You may find this question when trying to ignore a specific file that you may not want to include in an open source project, but one that fits a pretty common pattern for you and you may want to include it in your other projects. For example, you may want to reflexively run tests with the same command regardless of the language, and you may keep the fiddly details of this in a local file that you usually want checked in on private projects, but not on projects you're helping out with.

Say the file is called test there are two solutions. First, your bash alias can look something like this:

./test || ./.test

And you can add .test in your global git ignore.

Or you can follow the advice given here on how to create a local gitignore; but note that it will override your global git ignore, so you'll need to include whatever is in your global git ignore there too.



来源:https://stackoverflow.com/questions/5270917/why-doesnt-my-global-gitignore-file-ignore

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!