`include.path` options from git configuration are not followed
Labels: area/identitykind/bugpriority/backlog
Timeline
Eric L. Frederich (ericfrederich) opened
Setup
At the bottom of your ~/.gitconfig put the following.
# Allow local overrides (i.e. for work)
[include]
path = ~/.gitconfig.local
Then create a ~/.gitconfig.local file with the following contents.
# Overrides for work
[user]
email = myself@work.com
Verify Git understands this by running git config user.email and see that it gives myself@work.com.
Another useful command is git config --list --show-origin | grep email
Proposed solution
Running git bug user new, when providing a suggestion for name, email, etc should run the appropriate Git command to retreive the default (git config user.name instead of whatever it's doing now.
Why I do this
I manage my personal dotfiles with a Git repo and stow, which seems to be a common practice.
At work I maintain a fork of this repo which has stuff like my GPG keys, my work email, etc, etc. So I put that stuff in ~/.gitconfig.local which is included from ~/.gitconfig.
Thanks for your report. The "new identity" workflow currently reads from the local and global configuration scopes, but go-git still doesn't follow includes, so this is something git-bug will need to implement itself.
sudoforge commented (edited)
As an alternative workaround, you might consider changing how you override configuration. This is what I do, and it works exceptionally well for different "roles", e.g. personal or work.
1. My global git configuration has my default identity, e.g. personal identity.
➜ head -n3 ~/.config/git/config
[user]
name = me
email = foo@localhost
2. My git repositories are namespaced on disk
For example, git-bug lives at ~/code/github.com/git-bug/git-bug. You don't need to do this, but you do at least need to group your different roles under folders, e.g. ~/code/personal/... and ~/code/work-1/..., ~/code/work-2/..., etc.
3. Set up small configuration files for the non-default roles:
➜ head -n3 ~/.config/git/config.work
[user]
name = firstname lastname
email = me@company-domain.com
You can add any valid git configuration you want in here.
4. Use includeIf to load the alternate config files
Put one or more includeIf directives at the bottom of your global git configuration file. These tell git to load these other config files based of the directory of the repository you're in.
With this configuration, when in ~/code/work/some-repo, the ~/.config/git/config.work file will be loaded and settings defined within it will override earlier settings in your global config file.
sudoforge changed the title from `include.path` options from git configuration are not followed to `include.path` options from git configuration are not followed