There is no default global gitignore file unless you specify in Git configuration. The default ones are .git/info/exclude for specific repository and per-directory .gitignore.

Every time I create a new repository, I always end up writing the same glob pattern for Vim swap file again and again. Spending and wasting time for exactly same patterns.

1   Steps

1.1   Adding global gitignore file

1.1.1   Manually

If you want a global gitignore, then you can set up core.excludesfile with path to your global gitignore file, copy one you have been using from a repository to ~/.gitignore and add the following to ~/.gitconfig:


[core]
excludesfile = ~/.gitignore

It will work on all repositories.

1.1.2   Using git

If you don’t want to manually edit Git configuration file, you can simply run:


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

The configuration file will be updated automatically.

[via usevim: Global Git Ignore]

1.2   Adding ignore patterns

After setting up the ~/.gitignore to ~/.gitconfig, you can now add patterns to the ignore files just like you do with repository’s .gitignore.

GitHub maintains a collection of gitignore templates, that might give you some ideas to start.