[Git] How to Set Files to Ignore in All Git Repositories Using Global .gitignore

Tadashi Shigeoka ·  Thu, April 12, 2012

In Git, I created a .gitignore that applies to all repositories to prevent accidentally committing files like .DS_Store that I want to ignore.

Git

Creating and Editing ~/.gitignore

echo .DS_Store >> ~/.gitignore

Setting git to Use .gitignore Under Home Directory

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

Now, files specified in .gitignore under the home directory will be ignored in all git repositories.

By the way, this is properly documented in the .gitignore automatically generated by git init.

# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile ~/.gitignore_global

That’s all from the Gemba.

Reference Information

Various Convenient Settings You Want to Do When Starting to Use Git : Asial Blog

Setting Global .gitignore to Configure Files to Ignore in All git Repositories | WEB Design Tips