3 ms·
It's rather annoying that part of the config is stored in your local checked out copy of the repository (.git/config) and part of it is in a configuration file
by michaelmior 3y ago
It's rather annoying that part of the config is stored in your local checked out copy of the repository (.git/config) and part of it is in a configuration file that is checked into version control (.gitattributes).
- KolmogorovComp 3y agoThe 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
- tom_ 3y agoThat's because part of it is for you personally (the bit that dictates exactly which program gets run to render the diff), and part of it is for everybody (the bit that specifies the diff-related file type).
- michaelmior 3y agoSure, but unless I'm missing something, adding `sqlite3` into my `.gitattributes` is useless without manually doing extra work to specify the config. I get that it would be nice to be able to override this locally, but having no way to specify a default way to make this work feels broken.
- tom_ 3y agoHmm, I'm sure the question was originally simply about the data being stored in two separate places? - but, I checked again, and it's very clearly not.