Adding a Global Ignore File for Git

Quick setup of ignore files for Git. You can of course set these up per repo, but that gets a little old. Instead you can setup a single ignore file and link to it so that every repo refers to it.

For example, create a git ignore file in your home directory:

1
~/.gitignore_global

Fill it with regular files that you want to ignore:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#.gitignore

# Railo files #
######################
WEB-INF/

# Sublime files #
######################
*.sublime-project
*.sublime-workspace

# Misc files #
######################
*.yml
*.buildpath
*.settings
*.cache

# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon?
Thumbs.db
.project

Edit your main git config file (~/.gitconfig) and add a reference to this new global ignore file:

1
2
3
4
5
6
[user]
        name = xxxx xxxx
        email = joe@xxx.com

[core]
        excludesfile = /Users/computername/.gitignore_global

Or you can run the following command:

1
git config --global core.excludesfile ~/.gitignore_global

Now all your git projects will share the same ignore file :)

git

Comments