How to configure Git properly

Required Link to heading

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 Link to heading

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 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