How to configure Git properly

Required Link to heading

You need a name and email otherwise commits won’t work:

git config --global 'Your Name'
git config --global ''

Global .gitignore Link to heading

Don’t put junk like these in your poject’s .gitignore:


Use your own config:

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

Add the git directory to your .gitignore file:

# Required since .dockerignore is a symlink to this file.

Now you can execute the symlink command:

ln -s .gitignore .dockerignore

Line endings Link to heading

Some people use wrong line endings, set this to use the proper ones:

git config --global core.autocrlf input

Diff Link to heading

Show whitespace errors in terminal diffs:

git config --global diff.wsErrorHighlight all

Better diff output:

git config --global merge.conflictStyle zdiff3