Check what is already configured
git config --list --show-origin --show-scope--show-origin prints the file the value came from. --show-scope shows whether it was system, global, local, worktree, or command. Git config is layered — a repository value can override your global one.
Commit identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"These values become the author and committer recorded in every commit. They are not your GitHub/GitLab/SSH login.
If you use different emails for work and personal projects, make Git stop guessing:
git config --global user.useConfigOnly trueThen set the email inside each repository that needs a different identity:
git config user.email "you@company.example"Git will refuse to commit until you set it, which is better than discovering a work commit signed with a personal address.
Initial branch name
For repositories created with git init:
git config --global init.defaultBranch mainAffects new repositories only.
Editor that waits
Git opens an editor for commit messages, merges, rebase todos, and tags.
git config --global core.editor "vim"For GUI editors make sure the command waits:
git config --global core.editor "code --wait"Git must receive control back after you finish editing.
Credential helper
For HTTPS remotes, list the helpers available on your system:
git help -a | grep credential-On macOS:
git config --global credential.helper osxkeychainOther common choices: Git Credential Manager, libsecret on Linux desktops, Windows credential helpers.
Avoid credential.helper store unless you knowingly accept that credentials are written to disk unencrypted.
Aliases
git config --global alias.st "status --short --branch"
git config --global alias.lg "log --graph --decorate --oneline --all"
git config --global alias.last "log -1 HEAD --stat"git st— current branch and a compact file list.git lg— commit graph with branch and tag names. Drop--allif it gets too noisy in a particular repository.git last— last commit with stats.
Edit the file directly
For small one-off settings, git config --global key value is fine. Once there is more than a handful, edit the file:
git config --global --editRead a single value:
git config --global --get user.emailWhen something is set unexpectedly, the debugging tool is:
git config --list --show-origin --show-scope





