Private ignore files for Git and Mercurial
Sometimes you want to keep some files in your repository, but you don't want to commit them into your version control system. That's basically what .gitignore
or .hgignore
are for. Depending on the team size, this file can become quickly polluted with personal rules, like playground/
. It's much cleaner to define user-specific ignore rules in a second ignore file, which is stored locally:
Git
You can define per-repository rules in the .git/info/exclude
file, which is automatically created for every git repository.
Alternatively, you can define a custom ignore file (per-repo or globally):
1. Open {repo}/.git/config
or ~/.gitconfig
and add the following:
[core]
excludesfile = {path}/.gitignore.local
2. Create {path}/.gitignore.local
and add ignore rules the same way as in .gitignore
.
Mercurial
1. Open {repo}/.hg/hgrc
and add this:
[ui]
ignore.local = {repo}/.hgignore.local
Notice: you need to use an absolute path here.
2. Create {repo}/.hgignore.local
and define ignore rules the same way as in .hgignore
The idea of using a .local suffix comes from StackOverflow.
SVN
Unfortunately, there is no real alternative for SVN. However, some SVN clients (e.g. TortoiseSVN) provide a workaround using the ignore-on-commit
changelist to ignore files locally.