• First Git Config I Set on a New Machine

    Hands adjust the paper guides of a typewriter on a sunlit desk before a blank page is written.

    Check what is already configured

    bash
    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

    bash
    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:

    bash
    git config --global user.useConfigOnly true

    A configured global email still applies. Set a different address inside each repository that needs one:

    bash
    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:

    bash
    git config --global init.defaultBranch main

    Affects new repositories only.

    Editor that waits

    Git opens an editor for commit messages, merges, rebase todos, and tags.

    bash
    git config --global core.editor "vim"

    For GUI editors make sure the command waits:

    bash
    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:

    bash
    git help -a | grep credential-

    On macOS, osxkeychain remains an option for storing HTTPS credentials:

    bash
    git config --global credential.helper osxkeychain

    Other 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

    bash
    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 --all if 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:

    bash
    git config --global --edit

    Read a single value:

    bash
    git config --global --get user.email

    When something is set unexpectedly, the debugging tool is:

    bash
    git config --list --show-origin --show-scope