.gitconfig file contains configuration variables that control Git’s behavior. This reference covers the most commonly used configuration options.
File Format
Git configuration files use an INI-style format with sections and variables:Syntax Rules
- Section names are case-insensitive
- Variable names are case-insensitive
- Comments start with
#or; - Values can be quoted with double quotes
- Lines can be continued with backslash
\
Example
User Identity
user.name
user.name
Your name for commit author information.Configuration:
user.email
user.email
Your email address for commit author information.Configuration:
user.signingKey
user.signingKey
GPG key ID for signing commits and tags.For SSH signing:
user.useConfigOnly
user.useConfigOnly
Require user.email and user.name to be configured explicitly.Prevents Git from guessing identity, useful when managing multiple identities.
Core Settings
core.editor
core.editor
Default text editor for commit messages and interactive operations.
core.autocrlf
core.autocrlf
Line ending conversion behavior.Values:
true- Convert to CRLF on checkout, to LF on commitinput- Convert to LF on commit onlyfalse- No conversion
core.filemode
core.filemode
Track executable bit changes in file permissions.Set to
false on filesystems that don’t preserve executable permissions (like FAT32, some Windows systems).core.ignoreCase
core.ignoreCase
Treat filenames as case-insensitive.Automatically set by
git init on case-insensitive filesystems (APFS, HFS+, NTFS).core.excludesFile
core.excludesFile
Global gitignore file for all repositories.Configuration:
core.pager
core.pager
Program to use for paginated output.
Aliases
Create shortcuts for Git commands:Shell Aliases
Aliases starting with! execute as shell commands:
Branch Settings
init.defaultBranch
init.defaultBranch
Default branch name for new repositories.
branch.autoSetupMerge
branch.autoSetupMerge
Automatically set up tracking for new branches.Values:
true- Set up tracking when branching from remote branchalways- Set up tracking for all new branchesfalse- Never set up tracking automatically
branch.<name>.remote
branch.<name>.remote
Default remote for a specific branch.
branch.<name>.merge
branch.<name>.merge
Default merge target for a specific branch.
Color Configuration
color.ui
color.ui
Enable colored output globally.Values:
auto- Use colors when output is to a terminalalways- Always use colorsnever- Never use colors
Specific Color Settings
Specific Color Settings
Customize colors for different output types:Configuration:
Merge and Diff Settings
merge.tool
merge.tool
Default merge tool for resolving conflicts.
merge.conflictStyle
merge.conflictStyle
Conflict marker style.
diff.tool
diff.tool
Default diff tool.
diff.algorithm
diff.algorithm
Diff algorithm to use.Values:
myers, minimal, patience, histogramPush and Pull Settings
push.default
push.default
Default push behavior.Values:
simple- Push current branch to upstream (default)current- Push current branch to branch of same nameupstream- Push to configured upstreammatching- Push all matching branchesnothing- Require explicit refspec
push.autoSetupRemote
push.autoSetupRemote
Automatically create remote tracking branches.
pull.rebase
pull.rebase
Use rebase instead of merge when pulling.Values:
true- Rebase when pullingfalse- Merge when pulling (default)interactive- Interactive rebasemerges- Rebase and preserve merge commits
pull.ff
pull.ff
Fast-forward behavior when pulling.Values:
true- Fast-forward when possiblefalse- Always create merge commitonly- Only allow fast-forward
Credential Settings
credential.helper
credential.helper
Credential storage helper.
Remote Settings
remote.<name>.url
remote.<name>.url
URL for a remote repository.
remote.<name>.fetch
remote.<name>.fetch
Fetch refspec for a remote.
Advanced Settings
commit.gpgSign
commit.gpgSign
Sign all commits with GPG.
tag.gpgSign
tag.gpgSign
Sign all tags with GPG.
rerere.enabled
rerere.enabled
Enable reuse of recorded conflict resolutions.
help.autoCorrect
help.autoCorrect
Auto-correct typos after delay (in deciseconds).
Include Directives
Static Includes
Conditional Includes
includeIf gitdir
includeIf gitdir
Include configuration based on repository location.
includeIf onbranch
includeIf onbranch
Include configuration based on current branch.
Common Configuration Examples
Minimal Setup
Developer Setup
Work/Personal Split
~/.gitconfig:
~/.gitconfig-work:
~/.gitconfig-personal:
See Also
- Configuration Overview - Understanding Git configuration
- .gitignore - Ignore patterns for untracked files
- .gitattributes - Path-specific Git attributes
