4 ms·
The usual workaround is to create a config file, check it and symlink it to .git/config.
by KolmogorovComp 3y ago
The usual workaround is to create a config file, check it and symlink it to .git/config.
- IshKebab 3y agoThat sucks because then you can't have project and user-specific configs (e.g. setting your email address for a particular project).
- avar 3y agoThere's been occasional talk of implementing something like this on the Git ML & devloper summits (and I've probably been the most excited about it), but for now this is deliberate and symlinking a tracked file to .git/config is a big exploit vector, you're basically giving everyone who's got access to the repository shell access on your computer. That's because some configuration will allow you to execute arbitrary commands on the user's computer (aliases, but also various ..cmd config, etc.). Then there's other config that's also dangerous, but short of arbitrary code execution. So, if git ever does start supporting a "tracked config" it would involve being very careful about the security implications. The approach I've advocated for is similar to how Emacs handles this, i.e. to have the user whitelist certain configuration keys/value types as "safe"). But for now it's not supported at all, one workaround for what you may be trying to do is to do path-based includes. I.e. if the reason you're setting the user and/or E-Mail is e.g. for a personal or work configuration, then you could clone those projects in ~/git/personal or ~/git/work, and have your ~/.gitconfig set the configuration for those accordingly.
- michaelmior 3y agoThis is a fair point. Allowing a specific diff program to be specified in the repository configure would basically allow anyone with push access to your repository the possibility of executing arbitrary commands on your local machine.
- KolmogorovComp 3y agoHow often does that happen for you in practice? I’ve worked across hundreds of git repos with other teams, and I can count the ones were I had to fiddle with the git config on one hand. It’s still a workaround with limitations, but I have found it to work ok most of the time.
- IshKebab 3y agoAll the time because I occasionally do extra curricular work on my work laptop and I want to use my Gmail address for that, not my work email address.
- chrismorgan 3y agoThat’s not a usual workaround. That’s a crippled technique that doesn’t scale beyond single-user, single-branch usage, because .git/config includes things like the remotes and branches.
- liveoneggs 3y agoEven better - use an include/includeIf in your config