On Wed, Feb 22, 2017 at 06:42:02PM +0530, Tushar Kapila wrote: > Feature request : can we have a config for email per repo domain ? > Something like: > > git config --global domain.user.email tgkp...@test.xyz.com > testing.abc.doman:8080 > > git config --global domain.user.email tgkp...@xyz.com abc.doman:80 > > git config --global domain.user.email tgkp...@search.com github.com > > So when remote URL has github.com push as tgkp...@search.com but for > testing.abc.doman:8080 use tgkp...@test.xyz.com ?
The idea of "the domain for this repo" doesn't really match Git's distributed model. A repo may have no remotes at all, or multiple remotes with different domains (or even remotes which do not have a domain associated with them, like local files, or remote helpers which obscure the domain name). It sounds like you're assuming that the domain would come from looking at remote.origin.url. Which I agree would work in the common case of "git clone https://example.com", but I'm not comfortable with the number of corner cases the feature has. I'd much rather see something based on the working tree path, like Duy's conditional config includes. Then you write something in your ~/.gitconfig like: [include "gitdir:/home/peff/work/"] path = .gitconfig-work [include "gitdir:/home/peff/play/"] path = .gitconfig-play and set user.email as appropriate in each. You may also set user.useConfigOnly in your ~/.gitconfig. Then you'd have to set user.email in each individual repository, but at least Git would complain and remind you when you forget to do so, rather than silently using the wrong email. -Peff