How to configure Git properly

Required

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

git config --global user.name 'Your Name'
git config --global user.email 'your.email@faang.com'

Global .gitignore

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

.DS_Store
.idea/
*.swp

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.
/.git

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

Diff

Show whitespace errors in terminal diffs:

git config --global diff.wsErrorHighlight all