Git Config Cookbook

Ready-to-use Git configuration recipes for identity, pull/push policy, aliases, tools, safety, and performance.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Identity and UX Defaults
Set repo-specific user name
git config user.name "Project Identity"

# Override global identity in one repository.

Set pager
git config --global core.pager "less -FRX"

# Customize pager behavior.

Enable colors
git config --global color.ui auto

# Use color output automatically.

Set init.defaultBranch
git config --global init.defaultBranch main

# Choose default branch name for new repos.

Display columns
git config --global column.ui auto

# Format list commands in columns where supported.

Enable help autocorrect
git config --global help.autocorrect prompt

# Suggest or autocorrect mistyped commands.

## Pull, Push, and Merge Policy
Require fast-forward pulls
git config --global pull.ff only

# Fail pull if it would create a merge commit.

Rebase merges on pull
git config --global pull.rebase merges

# Rebase and preserve local merge structure.

Enable auto-stash on rebase
git config --global rebase.autoStash true

# Temporarily stash dirty worktree during rebase.

Use simple push default
git config --global push.default simple

# Push current branch to its upstream when names match.

Auto setup remote on first push
git config --global push.autoSetupRemote true

# Set upstream automatically for first push.

Prune on fetch
git config --global fetch.prune true

# Remove stale remote-tracking refs on fetch.

## Diff and Merge Tools
Use VS Code merge tool
git config --global merge.tool vscode

# Set preferred merge tool name.

Configure VS Code merge command
git config --global mergetool.vscode.cmd 'code --wait "$MERGED"'

# Define command for the merge tool.

Disable difftool prompt
git config --global difftool.prompt false

# Skip confirmation before launching external difftool.

Launch difftool
git difftool main..feature/my-change

# Run configured external diff viewer.

Launch mergetool
git mergetool

# Open merge tool for unresolved conflicts.

## Useful Aliases
Create graph log alias
git config --global alias.lg 'log --oneline --decorate --graph --all'

# Quick visual history alias.

Create last commit alias
git config --global alias.last 'log -1 HEAD --stat'

# Review most recent commit quickly.

Create unstage alias
git config --global alias.unstage 'restore --staged --'

# Shortcut to unstage files.

Create branches alias
git config --global alias.br 'branch -vv'

# Verbose local branch listing.

## Performance and Safety
Enable autocrlf on Windows
git config --global core.autocrlf true

# Normalize line endings for Windows users.

Force LF endings
git config --global core.eol lf

# Prefer LF working tree endings with normalization.

Tune auto gc threshold
git config --global gc.auto 256

# Adjust object count threshold for auto garbage collection.

Enable filesystem cache
git config --global core.fscache true

# Improve performance on some platforms.

Trust all directories
git config --global --add safe.directory '*'

# Allow all owned repositories; use carefully.

Sign commits by default
git config --global commit.gpgsign true

# Require commit signing when supported.