First-Time Setup

Configuring Git for the First Time

Every commit records an author name and email, and Git 1,932 refuses to commit until it has them. Set them once in your global file, ~/.gitconfig, with three settings that replace older defaults:

First-time Git configurationShell
git config set --global user.name "Sam Rivera"
git config set --global user.email "sam@example.com"
git config set --global init.defaultBranch main
git config set --global core.editor "nano"
git config set --global pull.ff only
git config list --global
Output
user.name=Sam Rivera
user.email=sam@example.com
init.defaultbranch=main
core.editor=nano
pull.ff=only

The set, get, list and unset subcommands arrived in Git 2.46; the older git config --global user.name "Sam Rivera" still works. Key names are case-insensitive, so Git prints them in lowercase. init.defaultBranch names new repositories' first branch main (Git's own default stays master until 3.0). core.editor opens for commit messages; for VS Code 550 use code --wait, or Git sees an empty message and aborts. pull.ff only stops git pull from creating surprise merge commits (Fetch vs Pull).

Git never verifies the email; hosting services use it to link commits to profiles (GitHub).