Identity, Email, and Essential Settings
Identity, Email, and Essential Settings
After this page every commit you make records a name and email you chose.
Identity is metadata, not a login
user.name and user.email are written into every commit. They are not a password and not a forge account. Forges match the email to an account when they display history. A typo produces “unknown author” on the website. git commit still succeeds.
~/.gitconfig
user.name = Ada Desk
user.email = ada@example.com
│
▼
commit object
tree …
parent …
author Ada Desk <ada@example.com> 1774… +0530
committer Ada Desk <ada@example.com> …
message …
git config --global user.name "Ada Desk"
git config --global user.email "ada@example.com"Use the email the forge should associate with you. For a first laptop, any address you control is fine. For work, the company address, often via includeIf from the previous page.
Refuse to commit if identity is missing, instead of guessing $USER@$HOSTNAME:
git config --global user.useConfigOnly trueCheck what will be recorded
git config user.name
git config user.email
git config --show-origin user.emailAfter you have a commit (chapter 3):
git log -1 --format=fullAuthor: is user.name <user.email> from the time of the commit. Changing ~/.gitconfig later does not rewrite old commits. Chapter 6 is amending; chapter 20 is signing.
Signing is later
Signed commits (SSH or GPG) prove the commit came from a key you hold. Set identity here first. Signing is chapter 20.
Essential settings, one list
If you jumped here from install, this is the whole global block this book expects:
git config --global user.name "Ada Desk"
git config --global user.email "ada@example.com"
git config --global user.useConfigOnly true
git config --global init.defaultBranch main
git config --global core.editor "nvim"
git config --global pull.ff onlyReplace the name, email, and editor with yours. Then pick SSH or HTTPS on the next page.