Last Updated: June 26, 2023
·
3.777K
· mdahlstrand

.gitexcludes

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

._*
.DS_Store
.AppleDouble
Thumbs.db
*.sublime-*
TODO
TEMP_*
.srvr*

(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!

6 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 ·

https://github.com/github/gitignore provides a whole bunch of sample ignore files.

For instance:

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

good advice, I recommend keeping it

over 1 year ago ·