Git Configuration
Tuesday, 28 January 2014, 20:54
In Git you can configure settings such as your username or email address on three different levels.
- System configuration: Configuration can be done at the system level, these settings will be used for all users and all repositories on the system. The system configuration is stored in %GIT_HOME%\etc\gitconfig.
- Global configuration: Settings can also be configured per user. Configurations done at this level will be used for every repository the user works on. The global configuration is stored the .gitconfig file in the users home directory.
- Repository configuration: It is possible to configure some settings at the repository level. The repository configuration is stored in \.git\config file in the repository.
- It is possible to override a setting made at a more general level on a more specific level. When settings are configured on more than one level the most specific settings will be used. When for example Bob is configured as username on the system level and Fred is configured on the repository level, Fred will be used as username when committing in the repository.
- Because I use a separate Git installation for each project all my configurations are done at the system level. This way all my configurations are nicely separated for each project and done in one place.
The code snippet below shows how a configuration can be added at the different levels and how the configurations at the different levels can be retrieved.
An overview of everything possible with the git config command can be found
here.