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.
To stop Git from guessing an identity when none is configured:
git config --global user.useConfigOnly trueA configured global email still applies. Set a different address inside each repository that needs one:
git config user.email "you@company.example"If you want Git to refuse commits until you choose an email per repository, leave user.email unset globally and in other inherited configuration. With user.useConfigOnly enabled, Git will not invent a fallback 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 GitHub, use Git Credential Manager for HTTPS or connect over SSH rather than manually managing personal access tokens. SSH does not use an HTTPS credential helper.
For HTTPS remotes, list the helpers available on your system:
git help -a | grep credential-On macOS, osxkeychain remains an option for storing HTTPS credentials:
git config --global credential.helper osxkeychainOther choices include libsecret on Linux desktops and 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





