Git Config Essentials

Set identity, defaults, and aliases for Git on a new machine.

  • git config
  • git identity
  • git alias
  • git default branch
  • git setup

Git Config Essentials

Set identity, defaults, and aliases for Git on a new machine.

Commands

CommandWhat it does
git config --global user.name "Your Name"Set commit author name
git config --global user.email "you@example.com"Set commit author email
git config --global init.defaultBranch mainNew repos default to main
git config --list --show-originShow all settings and where they come from
git config --global alias.st statusShortcut: git st for status
git config --global core.editor "code --wait"Use VS Code as commit editor

Example

git config --global user.name "Ada Lovelace"
git config --global user.email "ada@example.com"
git config --list | grep user

FAQ

Where is global config stored?

In ~/.gitconfig (or ~/.config/git/config); repo-local overrides live in .git/config.

How do I use a different identity for one repo?

Run git config user.email without --global inside that repo; it overrides the global value.

Câu hỏi thường gặp

Where is global config stored?
In ~/.gitconfig (or ~/.config/git/config); repo-local overrides live in .git/config.
How do I use a different identity for one repo?
Run git config user.email without --global inside that repo; it overrides the global value.

Git