Skip to content

Latest commit

 

History

History
118 lines (83 loc) · 2.36 KB

File metadata and controls

118 lines (83 loc) · 2.36 KB

Appendix A — Git Configuration Cheatsheet

Configuration Levels

git config --system   # /etc/gitconfig        (all users)
git config --global   # ~/.gitconfig           (your user)
git config --local    # .git/config            (this repo only)

Local overrides global, which overrides system.

Identity

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

Editor

git config --global core.editor "vim"
git config --global core.editor "code --wait"       # VS Code
git config --global core.editor "nano"
git config --global core.editor "subl -n -w"        # Sublime Text

Default Branch

git config --global init.defaultBranch main

Line Endings

# On macOS/Linux
git config --global core.autocrlf input

# On Windows
git config --global core.autocrlf true

Merge & Diff Tools

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

Pull Behavior

# Rebase by default (cleaner history)
git config --global pull.rebase true

# Only allow fast-forward pulls
git config --global pull.ff only

Push Behavior

# Push only the current branch
git config --global push.default current

# Auto set upstream when pushing a new branch
git config --global push.autoSetupRemote true

Colors

git config --global color.ui auto

Credential Caching

# Cache credentials in memory for 1 hour
git config --global credential.helper 'cache --timeout=3600'

# On macOS, use Keychain
git config --global credential.helper osxkeychain

# On Windows, use Credential Manager
git config --global credential.helper manager

Useful Misc Settings

# Show untracked files in subdirectories
git config --global status.showUntrackedFiles all

# Enable rerere (reuse recorded resolution)
git config --global rerere.enabled true

# Auto-correct typos (with 0.5s delay)
git config --global help.autocorrect 5

# Use histogram diff algorithm (better output)
git config --global diff.algorithm histogram

# Sign commits with GPG
git config --global commit.gpgsign true
git config --global user.signingkey YOUR_GPG_KEY_ID

View All Settings

git config --list --show-origin

This shows every setting and which file it comes from.