Introduce Multiple Git Users
New users of Git typically start with simple setups. But over time, the number of repositories grows. At some point, one will be eventually working with several remote servers and therefore different users. One may even come across repository-specific configurations. For this reason, it is useful to look at the organization of Git's configuration.
Git Configuration Levels
Git uses configuration files of different levels:
- system is located accessible for all users of the system.
- global is a configuration per system user.
- local is located in a specific repository.
This structure can be used place configuration options precisely where there are needed. But there is even another very useful way on top to handle different configurations: The files can be split and included conditionally. This allows to handle some further use cases and it comes handy if your system user has multiple Git users, e.g., per Git remote server.
Example
The example below shows three Git configurations at system user level (global).
In listing 1 is shown how the conditional includes work by including
configuration files depending on the current working directory. There is a
configuration to work with in path/to/my/personal/projects/
(see listing 2) and
a second one (see listing 3) for path/to/my/github/projects/
.
Note: The two ** include sub-folders recursively.
Published: