Darek Kay's picture Darek Kay

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:


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:

excludesfile = {path}/.gitignore.local

2. Create {path}/.gitignore.local and add ignore rules the same way as in .gitignore.


1. Open {repo}/.hg/hgrc and add this:

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.


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.

Related posts

Want to leave a comment?

If you want to give me some feedback, please contact me via Twitter or email. 💌

Private ignore files for Git and Mercurial