Git’s includeIf
directive allows for conditional inclusion of configuration files based on the repository path, enabling different configurations for projects in distinct directories.
Configuration Levels in Context
It’s important to understand Git’s configuration hierarchy:
- System: Applies to all users and their repositories on the computer.
- Global: User-wide settings that apply to all of the user’s repositories.
- Local: Specific to a single repository, these settings take precedence over system and global settings.
Conditional includes are typically part of the global configuration but are activated based on the current repository’s path.
Example Use Case
Use the following syntax in the global .gitconfig
to set up conditional includes:
Troubleshooting
- Local
.gitconfig
files can override global settings when within the specified directory. - Debug configurations with
git config --list --show-origin
.