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

Author, editor, pager, colors, branch names, and output settings.

Set repo-specific user name

Override global identity in one repository.

bashANYconfigidentity
bash
git config user.name "Project Identity"

Set pager

Customize pager behavior.

bashANYconfigpager
bash
git config --global core.pager "less -FRX"

Enable colors

Use color output automatically.

bashANYconfigcolor
bash
git config --global color.ui auto

Set init.defaultBranch

Choose default branch name for new repos.

bashANYconfigbranch
bash
git config --global init.defaultBranch main

Display columns

Format list commands in columns where supported.

bashANYconfigui
bash
git config --global column.ui auto

Enable help autocorrect

Suggest or autocorrect mistyped commands.

bashANYconfighelp
bash
git config --global help.autocorrect prompt

Pull, Push, and Merge Policy

Defaults that shape collaboration and history style.

Require fast-forward pulls

Fail pull if it would create a merge commit.

bashANYconfigpull
bash
git config --global pull.ff only

Rebase merges on pull

Rebase and preserve local merge structure.

bashANYconfigpullrebase
bash
git config --global pull.rebase merges

Enable auto-stash on rebase

Temporarily stash dirty worktree during rebase.

bashANYconfigrebase
bash
git config --global rebase.autoStash true

Use simple push default

Push current branch to its upstream when names match.

bashANYconfigpush
bash
git config --global push.default simple

Auto setup remote on first push

Set upstream automatically for first push.

bashANYconfigpush
bash
git config --global push.autoSetupRemote true

Prune on fetch

Remove stale remote-tracking refs on fetch.

bashANYconfigfetch
bash
git config --global fetch.prune true

Diff and Merge Tools

External diff/merge tool integration.

Use VS Code merge tool

Set preferred merge tool name.

bashANYconfigmerge-tool
bash
git config --global merge.tool vscode

Configure VS Code merge command

Define command for the merge tool.

bashANYconfigmerge-tool
bash
git config --global mergetool.vscode.cmd 'code --wait "$MERGED"'

Disable difftool prompt

Skip confirmation before launching external difftool.

bashANYconfigdifftool
bash
git config --global difftool.prompt false

Launch difftool

Run configured external diff viewer.

bashANYdifftool
bash
git difftool main..feature/my-change

Launch mergetool

Open merge tool for unresolved conflicts.

bashANYmergetool
bash
git mergetool

Useful Aliases

High-value aliases for faster everyday use.

Create graph log alias

Quick visual history alias.

bashANYconfigalias
bash
git config --global alias.lg 'log --oneline --decorate --graph --all'

Create last commit alias

Review most recent commit quickly.

bashANYconfigalias
bash
git config --global alias.last 'log -1 HEAD --stat'

Create unstage alias

Shortcut to unstage files.

bashANYconfigalias
bash
git config --global alias.unstage 'restore --staged --'

Create branches alias

Verbose local branch listing.

bashANYconfigalias
bash
git config --global alias.br 'branch -vv'

Performance and Safety

Settings for large repos, line endings, and repository trust.

Enable autocrlf on Windows

Normalize line endings for Windows users.

bashWINDOWSconfigline-endings
bash
git config --global core.autocrlf true

Force LF endings

Prefer LF working tree endings with normalization.

bashANYconfigline-endings
bash
git config --global core.eol lf

Tune auto gc threshold

Adjust object count threshold for auto garbage collection.

bashANYconfiggc
bash
git config --global gc.auto 256

Enable filesystem cache

Improve performance on some platforms.

bashANYconfigperformance
bash
git config --global core.fscache true

Trust all directories

Allow all owned repositories; use carefully.

bashANYconfigsecuritydanger
bash
git config --global --add safe.directory '*'

Sign commits by default

Require commit signing when supported.

bashANYconfiggpgsign
bash
git config --global commit.gpgsign true