Useful Git Configuration Items

Name and email address

Each commit you make has your name and email address attached to it. Git will automatically configure these based on your username and hostname, but this information is usually not a good identifier. It is a good idea to set your real name and email address so that your commits can be identified easily.

git config --global user.name "Your Name"
git config --global user.email you@yourdomain.com

Global ignore file

Often there are files or directories that you want to ignore in all your Git projects. These are probably created automatically by your IDE, or ‘junk’ files created by the operating system. Here’s a sample global ignore file (I use PhpStorm, which creates an .idea directory in the root of each project):

Thumbs.db
.DS_Store
.idea

Save the file somewhere, and run git config --global core.excludesfile /path/to/.gitignore_global

Enable coloured output

git config --global color.ui true

Prevent line ending issues

On Linux and Mac

git config --global core.autocrlf input

On Windows

git config --global core.autocrlf true

See http://help.github.com/line-endings/ for more information.

Add SVN-like shortcuts

git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch

Better compression

git config --global core.compression 9

If you find that Git is taking too long to compress objects, you can play around with this value. A value of 0 tells Git to use no compression. Values 1-9 are various speed/size tradeoffs where 1 is the fastest and 9 provides the best compression. A value of -1 lets zlib decide which compression level to use.

  • http://twitter.com/timmow Tim Mower

    I find git config –global color.ui true is simpler and gives a smaller config

    I find the behaviour of the pager to be annoying by default, as it will page even if less than a full screen of input to fix this

    git config –global core.pager ‘less -FRSX’

    And finally, I prefer to do a git pull –rebase on remote branches before pushing, you can get this behaviour by default on new branches by doing

    git config –global branch.autosetuprebase=always