Git uses configuration files to store settings that control its behavior. These settings can be applied at different levels, influencing how Git works for specific repositories, users, or even the entire system.
There are three main types of configuration files:
1. System-wide configuration:
2. Global configuration:
3. Repository-specific configuration:
When Git looks for a configuration value, it checks the files in this order:
The last file found takes precedence.
You can use the `git config` command to set, get, and unset configuration options. Some common options include:
git config --global user.name "Your Name" git config --global user.email "[email protected]"
git config --global core.editor "vim"
git config --global diff.tool vimdiff
git config --global alias.co checkout git config --global alias.br branch
git config --global merge.tool vimdiff
[user] name = Your Name email = [email protected]
[core] editor = vim
[alias] co = checkout br = branch
To view your current configuration, use:
git config --list
You can also edit the configuration files directly. However, using the `git config` command is often more convenient and ensures correct syntax.
By understanding Git configuration files, you can customize your Git experience to suit your preferences and workflow.