AI Hints
Home›Git & GitHub Tutorial›Tools and Hooks
Git & GitHub · Lesson 114 of 144

Your Git Settings

The .gitconfig file.

⏱ 2 min read▶ Video at 2:05:00🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

All those git config commands write to one file, in your home folder, called dot git config. Let's look at it, and add a few settings that make life easier.

Your Git Settings
From the video: Your Git Settings
  • git config writes to a file
  • ~/.gitconfig
  • A few useful settings

Useful settings

Init dot default branch main makes new repositories start with main. Core dot editor sets the editor Git opens, here VS Code. And pull dot rebase, which we met earlier. Cat shows they're all in the file, in neat sections.

git
git config --global init.defaultBranch main
git config --global core.editor "code --wait"
git config --global pull.rebase false
cat ~/.gitconfig
[user]
        name = Sam Lee
        email = sam@example.com
[alias]
        st = status
[init]
        defaultBranch = main
[core]
        editor = code --wait
[pull]
        rebase = false

Three levels

Settings can live at three levels. System, for every user on the computer. Global, for you, in your home folder. And local, for one repository, stored inside its dot git folder. The most specific one wins, so a local setting beats a global one.

keyvalue
--systemevery user
--globalyou, ~/.gitconfig
--localone repository
Winsthe most specific

Summary

Your global settings live in dot git config in your home folder, and local settings beat global ones. Next, a few everyday gotchas, starting with line endings.

Key takeaways
  • ~/.gitconfig
  • init.defaultBranch, core.editor
  • local beats global
Next up: Line Endings — Windows, Mac and Linux