CodeshipStephen Connolly1 min readintermediate
Today I Learned: .gitconfig's includeIf
Summary
Use Git's `includeIf` conditional includes to automatically load per‑directory `.gitconfig` files, letting you set different `user.email` and `signingkey` values for Apache, work, and personal repos without manual `git config` calls.
- Git supports conditional includes via `includeIf "gitdir:<path>"` to load extra config files based on the repository location.
- Store per‑context identity settings (email, GPG signing key) in separate config files and reference them from `~/.gitconfig`.
- Organise your code checkout directories (e.g., `~/apache/` for Apache projects, `~/src/` for work) so the `gitdir` pattern matches correctly.
- This approach eliminates the need to remember to run `git config user.email …` for each repo.
Consistent author identity is required for auditability, proper attribution, and GPG‑signed commits. Automating the selection of email and signing key reduces human error and streamlines workflow across multiple organizations.
6/10