Git’s configuration system allows you to customize Git’s behavior at multiple levels. Configuration variables control everything from user identity to merge strategies, color output, and network protocols.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/git/git/llms.txt
Use this file to discover all available pages before exploring further.
Configuration Files
Git reads configuration from multiple files in a specific hierarchy:System Level
Location:/etc/gitconfig
System-wide configuration affecting all users and repositories on the machine. Requires administrator privileges to modify.
Global (User) Level
Location:~/.gitconfig or $XDG_CONFIG_HOME/git/config
User-specific configuration applying to all repositories for the current user. This is the most common place for personal settings.
Local (Repository) Level
Location:.git/config
Repository-specific configuration. This is the default scope when running git config inside a repository.
Worktree Level
Location:.git/config.worktree
Worktree-specific configuration (when extensions.worktreeConfig is enabled).
Configuration Precedence
When Git looks up a configuration value, it checks files in this order (last match wins):- System config (
/etc/gitconfig) - Global config (
~/.gitconfig) - Local config (
.git/config) - Worktree config (
.git/config.worktree)
Basic Commands
View Configuration
Set Configuration
Unset Configuration
Edit Configuration
Essential Configuration Variables
User Identity
User Identity
Required for creating commits:
Default Editor
Default Editor
Set your preferred text editor:
Default Branch Name
Default Branch Name
Set the default branch name for new repositories:
Aliases
Aliases
Create shortcuts for common commands:
Line Endings
Line Endings
Configure how Git handles line endings:
Color Output
Color Output
Enable colored output:
Configuration File Syntax
Git configuration files use INI-style syntax:Example Configuration
Conditional Includes
You can include different configuration files based on conditions:Use Cases
Different identities for work and personal projects:~/.gitconfig:
~/.gitconfig-work:
Value Types
Boolean
True values:true, yes, on, 1False values:
false, no, off, 0, empty string
Integer
Supports suffixes:k, M, G (1024-based)
String
Color
Path
Supports tilde expansion:Best Practices
Set User Identity
Always configure
user.name and user.email before making commitsUse Global for Personal Preferences
Store editor, aliases, and UI preferences in global config
Use Local for Repository-Specific Settings
Override email, hooks, or workflow settings per repository
Use Conditional Includes
Separate work and personal configurations automatically
Troubleshooting
Find Where a Setting Comes From
Check All Values for a Variable
Verify Configuration is Valid
See Also
- .gitconfig Reference - Detailed configuration variables
- .gitignore - Ignore patterns for untracked files
- .gitattributes - Path-specific Git attributes
