GIT ignore – Ignore all auto generated OSX and IDE generated files globally

Creating a global .gitignore

Posted on July 23, 2014

Tags:

GIT

Save yourself some time by setting a global GIT ignore file to automatically ignore any auto generated files that you don’t want to commit to your repo such as .DS_Store generated by OSX and .idea generated by PHP Storm.

The setup’s pretty quick and simple through the command line:

Create a global git ignore file. I do this in my User directory:

touch ~/.gitignore_global

Edit the file and add your ignore rules. I use nano for editing:

nano ~/.gitignore_global
# OSX generated files #
#######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes

# PHPStorm generated files #
############################
.idea/

Save and exit nano:

ctrl+o
ctrl+x

…and there you have it, no more manually ignoring files in GIT for each project.