HOW-TO: Create a global git ignore file

If you work on web projects day in and day out, you might want to make sure pesky cruft files don't get accidentally commited when you push code upstream.

A great way to achieve this goal is to create a global git ignore file. To do this, first configure git to read this global git ignore file (you can name it what you want)

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

Then edit the ~/.gitignore\_global file and add a few ignore lines:

$ vim ~/.gitignore\_global

Here's what I recommend:

\# Packages 

\*.7z  
\*.dmg  
\*.gz  
\*.iso  
\*.jar  
\*.rar  
\*.tar  
\*.zip

\# Logs and databases

\*.log  
\*.sql  
\*.sqlite

\# OS generated files

.DS\_Store  
.DS\_Store?  
.\_\*  
.Spotlight-V100  
.Trashes  
ehthumbs.db  
Thumbs.db

\# Ignore configuration files that may contain sensitive information.  
sites/\*/\*settings\*.php

\# Ignore paths that contain generated content.

files/  
sites/\*/files  
sites/\*/private

\# Ignore default text files  
robots.txt  
/CHANGELOG.txt  
/COPYRIGHT.txt  
/INSTALL\*.txt  
/LICENSE.txt  
/MAINTAINERS.txt  
/UPGRADE.txt  
/README.txt  
sites/all/README.txt  
sites/all/modules/README.txt  
sites/all/themes/README.txt

\# Ignore everything but the "sites" folder ( for non core developer )  
#.htaccess  
#web.config  
#authorize.php  
#cron.php  
#index.php  
#install.php  
#update.php  
#xmlrpc.php  
#/includes  
#/misc  
#/modules  
#/profiles  
#/scripts  
#/themes