How can I display all global Git configuration settings? I want to see all configured Git sections, not just specific values like the default editor. I’ve tried git config --get core.editor but need to output everything configured globally.
To display all global Git configuration settings, use the command git config --global --list. This command will show every configuration setting that has been configured globally across all sections, including user information, repository preferences, and custom settings. Unlike git config --get core.editor which retrieves a specific value, this command outputs your entire global Git configuration in a list format that’s easy to read and manage.
- Basic Command Syntax
- Understanding Global Configuration
- Filtering and Sorting Options
- Alternative Display Methods
- Editing Global Configuration
- Troubleshooting Configuration Issues
Basic Command Syntax
The fundamental command to display all global Git configuration settings is:
git config --global --list
This command retrieves and displays all configuration settings that have been set at the global level. The output typically includes multiple lines, each showing a configuration key-value pair in the format key=value.
For example, your output might look like this:
user.name=John Doe
user.email=john.doe@example.com
core.editor=vim
init.defaultbranch=main
alias.st=status
alias.co=checkout
color.ui=true
The --global flag specifies that Git should look in the global configuration file, which is typically located at ~/.gitconfig on Unix-like systems or C:\Users\YourUsername\.gitconfig on Windows.
Note: If you omit the --global flag and just use git config --list, Git will display configuration settings from multiple levels: system, global, and local to the current repository, in order of decreasing priority.
Understanding Global Configuration
Git stores configuration settings in several locations, with each level having different precedence:
- System level:
/etc/gitconfig(requires admin privileges) - Global level:
~/.gitconfig(user-specific settings) - Local level:
.git/config(repository-specific settings)
When you use git config --global --list, you’re specifically asking for settings from the global configuration file. These settings apply to all repositories for your user account on that machine.
The global configuration file contains preferences that are common across your Git work, such as:
- Your name and email address for commits
- Default editor and merge tools
- Color preferences and display settings
- Custom aliases and shortcuts
- Credential helper configurations
- Proxy settings and network configurations
Key insight: Global configuration settings are user-specific and persist across different repositories, making them ideal for personal preferences and account information that shouldn’t be repeated in every repository.
Filtering and Sorting Options
While git config --global --list shows all global settings, you often need to filter or organize the output for better readability:
Filtering by Section or Key
To find specific settings within the global configuration:
git config --global --list | grep "user"
This will show only configuration keys containing “user” in the output.
Filtering by Exact Key
To see all configuration variables that match a specific pattern:
git config --global --list | grep -E "alias\.(st|co|br)"
This shows only aliases starting with “st”, “co”, or “br”.
Sorting Configuration
To sort configuration alphabetically:
git config --global --list | sort
Getting Configuration Values for Specific Keys
If you want to see the value for a specific key:
git config --global --get user.name
Showing Configuration Sources
To see which configuration file each setting comes from:
git config --global --list --show-origin
This outputs each setting with its file location, helping you understand where each configuration is defined.
Pro tip: Use git config --global --list --show-origin | grep "global" to see only global-level settings with their file paths for better organization.
Alternative Display Methods
Several alternative approaches can help you view and manage your global Git configuration:
Using Git Configuration Files Directly
You can also view and edit the global configuration file directly with any text editor:
# On Unix-like systems
cat ~/.gitconfig
# On Windows
type %USERPROFILE%\.gitconfig
This shows the raw configuration file content, which can be useful for manual editing or understanding the file structure.
Using JSON Format
For programmatic access or better parsing:
git config --global --list --json
This outputs configuration in JSON format, which is easier to parse by scripts.
Interactive Configuration Editor
Git provides an interactive way to edit configuration:
git config --global --edit
This opens your global configuration file in your default editor, allowing you to make changes directly.
Configuration Hierarchy
To understand the complete configuration hierarchy:
git config --list --show-origin
This shows all configuration settings from all sources (system, global, local) with their file paths.
Best practice: For regular use, git config --global --list is sufficient, but when debugging configuration issues or managing complex setups, the --show-origin flag provides valuable context about where each setting comes from.
Editing Global Configuration
After viewing your global configuration, you may want to modify it. Here are the common methods:
Using Command Line
Add or modify settings using:
git config --global --add key value
git config --global --set key value
git config --global --unset key
Manual File Editing
Open the global configuration file directly:
# On Unix-like systems
vim ~/.gitconfig
# On Windows
notepad %USERPROFILE%\.gitconfig
Common Global Settings
Some frequently configured global settings include:
# Set user information
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Configure default editor
git config --global core.editor "vim"
# Set default branch name
git config --global init.defaultbranch main
# Configure colors
git config --global color.ui true
# Create useful aliases
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
# Configure credential helper
git config --global credential.helper store
Caution: When editing configuration manually, ensure you follow the proper syntax. Each section should be in brackets [section], and key-value pairs should be on separate lines as key = value (spaces around the equal sign are optional but recommended for readability).
Troubleshooting Configuration Issues
When global configuration isn’t working as expected, consider these troubleshooting steps:
Verify Configuration Location
Check that your global configuration file exists and is accessible:
ls -la ~/.gitconfig
Check Configuration Priority
If settings aren’t applying as expected, check the configuration hierarchy:
git config --list --show-origin
This shows which configuration file is taking precedence for each setting.
Reset Configuration
If you need to reset global configuration:
# Remove specific setting
git config --global --unset key
# Remove entire section
git config --global --remove-section section
Validate Configuration Syntax
Check for syntax errors in your configuration file:
git config --global --list
If there are syntax errors, Git may not load all settings properly.
Configuration File Permissions
Ensure your configuration file has proper permissions:
chmod 644 ~/.gitconfig
Troubleshooting checklist: 1. Verify the global config file exists and is readable
2. Check for syntax errors in the configuration
3. Use --show-origin to understand configuration precedence
4. Look for conflicting settings in different configuration files
5. Check that configuration modifications are properly saved
Conclusion
Displaying all global Git configuration settings is straightforward using the git config --global --list command, which provides a comprehensive view of all user-specific Git preferences. This command outputs every global setting in a readable format, making it easy to review and manage your Git environment.
- Use
git config --global --listas your primary command to view all global settings - Combine with
grepandsortfor better organization and filtering - Use
--show-originto understand where each configuration comes from - Regularly review your global configuration to ensure it reflects your current preferences and needs
- Consider organizing related settings into logical sections for better maintenance
For most users, checking global configuration once or twice a month is sufficient to ensure everything is properly configured. However, if you’re setting up a new development environment or troubleshooting Git behavior, understanding and reviewing your global configuration becomes essential for maintaining a smooth workflow.