The “git config” command is used to manage custom configuration options for Git repositories. Git allows you to customize various aspects of its behavior through configuration settings. These configurations can be set at different levels: local (specific to the current repository) or global (applied to the current user across all repositories).
When you run the “git config” command without any arguments, it displays the current configuration settings for the repository or user, depending on the context. If you specify a configuration option, you can either set its value or retrieve its current value.
The configuration options in Git are extensive, allowing you to customize various aspects such as user identity, commit behavior, remote repository settings, aliases, and more. You can refer to the official Git documentation for a comprehensive list of configuration options and their meanings.
git config Command Examples
1. List only local configuration entries (stored in .git/config in the current repository):
# git config --list --local
2. List only global configuration entries (stored in ~/.gitconfig):
# git config --list --global
3. List only system configuration entries (stored in /etc/gitconfig), and show their file location:
# git config --list --system --show-origin
4. Get the value of a given configuration entry:
# git config alias.unstage
5. Set the global value of a given configuration entry:
# git config --global alias.unstage "reset HEAD --"
6. Revert a global configuration entry to its default value:
# git config --global --unset alias.unstage
7. Edit the Git configuration for the current repository in the default editor:
# git config --edit
8. Edit the global Git configuration in the default editor:
# git config --global --edit