Useful Options When Configuring Git
Note: This is an older post which was migrated to Ghost.
I’ve gathered these configuration options from multiple sources such as Github, the git manual and the rest of the interwebs. If you have any useful additions, please leave them in the comments below.
Setting the author name and email
Highly recommended and especially important when you’re going to collaborate.
git config --global user.name "Your name" git config --global user.email "email@example.com"
Although Mac’s don’t use CLRF line endings, you might accidentally add files that have CRLF line endings. This option will convert those CRLF to LF line endings on commit.
git config --global core.autocrlf input
Setting the default editor
Although some might prefer a bash editor, I like Sublime as the default. You can, of course, change to whatever editor you like best – as long as they support opening files from the terminal.
git config --global core.editor "subl -w"
Enabling terminal coloring
A bit of coloring makes it easier to differentiate data (and provides you a warm & fuzzy feeling on the inside).
git config --global color.diff auto git config --global color.status auto git config --global color.branch auto git config --global color.interactive auto
Aliases are (in this instance) shorthands to most-used functions Instead of typing ‘git log –online’ you can use 'git lp' to get a one-lined log of commits. Same goes for the other commands. You can, of course, add your own.
git config --global alias.ci commit git config --global alias.co checkout git config --global alias.st status git config --global alias.lp "log --oneline"
Globally ignored files
When don’t want certain files to get in your repositories, like those pesky .DS_Store files, you can tell git to ignore them globally.
echo ".DS_Store" > ~/.gitignore git config --global core.excludesfile ~/.gitignore
That’s it for now. I’ll be sure to update this post when I stumble into useful additions.