$ 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).
git config --global core.excludesfile ~/.gitignore
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.