Git Config

Configure Git with your name, email, and default settings. Learn global vs local configuration and essential first-time setup commands.

On this page

Why configuration matters

Every Git commit stores the author name and email. You must configure Git before making commits.

Set your username and email

git config --global user.name 'Your Name'
git config --global user.email 'you@example.com'

Global vs local configuration

  • Global: Applies to all repositories on your computer.
  • Local: Applies only to the current repository.
# Local configuration
git config user.name 'Project Specific Name'

View your configuration

git config --list

Set default branch name

git config --global init.defaultBranch main

Set default editor

git config --global core.editor 'code --wait'

Where config is stored

  • Global config is stored in your user directory.
  • Local config is stored inside the .git folder of the repository.