Every commit is stamped with your identity, and a few defaults save pain later.
Install Git from your package manager (apt install git, brew install git, winget install Git.Git) or from git-scm.com, then check it with git --version.
Before your first commit, tell Git who you are. Name and email are written into every commit you make, so use the email your hosting account knows about:
git config --global user.name "Ada Lovelace"
git config --global user.email "ada@example.com"git config works at three levels, each overriding the one before:
--system: every user on the machine.--global: you, stored in~/.gitconfig.--local(the default inside a repo): one repository, stored in.git/config.
So you can keep a personal email globally and override it with a work email inside work repositories. git config --list --show-origin shows every value and which file it came from, which is the quickest way to debug a surprising setting.
A few settings worth setting on day one:
init.defaultBranch mainso new repositories start onmain.core.editorto an editor you can use ("code --wait",nano,vim), because Git opens it for commit messages.pull.rebase false(ortrue) sogit pullknows how to combine diverged histories instead of asking every time.
On Windows, core.autocrlf true converts line endings for you; on macOS/Linux leave it unset or input.
Example
git --version # git version 2.51.0
git config --global user.name "Ada Lovelace"
git config --global user.email "ada@example.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait"
git config --global pull.rebase false
git config user.email # read one value
git config --list --show-origin # every setting and its fileRemember
- Set user.name and user.email before your first commit
- Config levels: system < global (~/.gitconfig) < local (.git/config)
- git config --list --show-origin explains where a value comes from
Watch out for
- Committing with a wrong email — the commits won't be linked to your hosting account and fixing them later means rewriting history.