0

I'm looking for a way to work with multiple users of mine with GIT.
I want to be able to switch easily user-specific configurations, that I need at the moment.

Something like a group flag for a bunch of settings in .gitconfig.

I saw this question, but couldn't find satisfaction in the suggested answers:

  1. The selected answer suggests to use the git config command in the repo, but it's error prune and not so comfortable to do it every time.
  2. The answer about the folder conditional include is very nice, but it will work only if there's a specific rule for the folder matching those configurations, which there isn't, since it's not necessarily under the same path.

Any other possible solution I'm missing?

What I thought about, in case there isn't a builtin/known way, is to write a script that will get a parameter of the current environment name I want and will run some git config commands locally on the current repo folder.

arieljannai
  • 2,124
  • 3
  • 19
  • 39
  • Do you want to specify which group you are using each time? – Joseph K. Strauss May 28 '18 at 19:35
  • What's wrong with 2? You only need to do it once per project. – jingx May 28 '18 at 19:40
  • @JosephK.Strauss Might be something like different name, email, CRLF replacement, mergetool etc. – arieljannai May 29 '18 at 10:38
  • @jingx I clarified that point, the thing is that it's not necessarily under the same folder path, so I can't use the `gitdir` option – arieljannai May 29 '18 at 10:39
  • But surely each project has a fixed root path, so you just need to add 2 lines for each project. Also it supports glob: https://git-scm.com/docs/git-config#_includes – jingx May 29 '18 at 11:56
  • Of course, but then I'll need to update the `.gitconfig` each time. But you gave me an idea with the blob - do you know in which part the configuration update takes place? on `git init` I guess? If so, maybe I can create a file name `config.personal` / `config.work` etc. and set the blob to match it – arieljannai May 29 '18 at 13:21

0 Answers0