Last Updated: February 25, 2016
· mdahlstrand


Setting up a .gitexcludes file means you'll never accidentally commit something you didn't intend to, just like a .gitignore file, but for all your local repositories.

Create your excludes file

touch ~/.gitexcludes

Add some useful ignores


(follows the same format as .gitignore)

Update git's config

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

And we're done!

Enjoy never again being the one who added all those pesky .DS_Store files to the repo!

5 Responses
Add your response

Might want to add .*.sw[op] for temporary Vim files.

over 1 year ago ·

I didn't know about this, NICE!

over 1 year ago ·

Great tip, as for vim swap files? I'd just disable them in vim, I've never had to use em

over 1 year ago ·

Oh, nice tip. I'm surprised why is it not named something like global_gitignore maybe.

over 1 year ago · provides a whole bunch of sample ignore files.

For instance:

cd $HOME/workspace/
git clone
git config --global core.excludesfile $HOME/workspace/gitignore/Global/Eclipse.gitignore
over 1 year ago ·