How to configure Git properly


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

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

Global .gitignore

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

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

git config --global core.autocrlf input


Show whitespace errors in terminal diffs:

git config --global diff.wsErrorHighlight all