bashbeginner

Git Config — Essential Global Settings

Configure Git globally with aliases, default branch, editor, credentials, and performance settings.

bash
# --- Identity ---
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

# --- Default branch name ---
git config --global init.defaultBranch main

# --- Editor ---
git config --global core.editor "code --wait"

# --- Diff and merge tool ---
git config --global diff.tool vscode
git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'
git config --global merge.tool vscode

# --- Useful aliases ---
git config --global alias.st  'status -sb'
git config --global alias.co  'checkout'
git config --global alias.br  'branch'
git config --global alias.ci  'commit'
git config --global alias.lg  'log --graph --oneline --all --decorate'
git config --global alias.last 'log -1 HEAD --stat'
git config --global alias.undo 'reset --soft HEAD~1'
git config --global alias.amend 'commit --amend --no-edit'
git config --global alias.wip  '!git add -A && git commit -m "WIP"'

# --- Performance ---
git config --global core.fsmonitor true
git config --global core.untrackedcache true

# --- Auto-correct ---
git config --global help.autocorrect 20   # auto-run after 2s

# --- Rebase on pull ---
git config --global pull.rebase true

# --- View all config ---
git config --global --list

Sponsored

GitHub Copilot

Use Cases

  • Setting up Git on a new machine
  • Standardizing config across a team
  • Productivity aliases for daily workflows

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.