skip to content

Git Ignore All The Crap, Globally

Git Logo

When working with Git, there are files you never want to commit, never ever: .DS_Store anyone?

Those are typically temporary files or files containing metadata only useful to your tools like last position of windows in your favorite IDE.

Most projects have their own .gitignore file that would exclude the kind of files mentioned above. Nevertheless, it doesn’t hurt to have a global .gitignore that prevents you from committing crap into your various Git repositories.

Here is my global ~/.gitignore file (edit it depending on your exact needs)

# Visual Studio specific files
*.user
*.ncb
*.sbr
*.suo
*.ilk
*.bsc
*.pdb
*.aps
*.pch
*.sdf
*.opensdf
*.sln.docstates
ipch/

# Xcode specific files
*.pbxuser
*.ext
*.mode1v3
*.perspectivev3
xcuserdata/

# Autotools specific files
*.sym
Makefile.in
config.h.in
autom4te.cache/
build-aux/
configure

# Miscellaneous build files
build/
obj/
*.obj
*.o

# Vi / Vim files
*~
.*.swp

# Finder crap
.DS_Store

# Various temporary folders
temp/
tmp/
.tmp/

# Git
*.orig
*.rej

Now to setup your global .gitignore, launch the following command:

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

See the core.excludesfile section in git-config manual.