0

I've tried to look for a way to match on a path using git config. I've only found (and tested) some mentioned in the link here, among others. Multiple git accounts: no .ssh/config or SSH agent usage

I have also read through https://git-scm.com/docs/gitcredentials but either didn't understand how to use these wildcards or they just didn't work as I thought they would. I currently have this setup:

[core]
    editor = \"C:\\Users\\anton\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" --wait
    sshCommand = C:/Windows/System32/OpenSSH/ssh.exe
[user]
    name = firstuser
    email = firstuser@gmail.com
[filter "lfs"]
    process = git-lfs filter-process
    required = true
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
[merge "ours"]
    driver = true

[credential "https://github.com/workuser/*"]
    username = workuser
    useHttpPath = true
    helper = wincred

[credential "https://github.com/firstuser/*"]
    username = firstuser
    useHttpPath = true
    helper = wincred

[credential "https://gitlab.com"]
    username = firstuser@gmail.com
    # useHttpPath = true
    helper = wincred

Using ssh for them worked fine, but I remember it can be an issue when behind a firewall and such.

It'd be nice if I could just match on the path of git and have it group all paths that match with it to use the same credentials. But perhaps I'm not seeing the issue with that. And if I'm doing something wrong, please tell me!

Thank you kindly in advance.

Anton Blomström
  • 1,353
  • 2
  • 7
  • 7
  • How often are you behind a firewall that blocks ssh? And would a VPN solve that? – Schwern Oct 12 '20 at 00:34
  • That would certainly solve the firewall issue. I'm just hoping I'm missing something here though, it seems like a nice feature to have unless there isn't some glaring security issue with it. Also, I didn't mean to put useHttpPath on the gitlab one since I only have one of those. – Anton Blomström Oct 12 '20 at 00:44
  • Does [this Git FAQ entry](https://git-scm.com/docs/gitfaq#Documentation/gitfaq.txt-HowdoIusemultipleaccountswiththesamehostingproviderusingHTTP) answer your question? – bk2204 Oct 12 '20 at 00:47
  • Yeah, I did try that and couldn't get it to work. But not quite like they show it there. Going back into the file history, I seem to have tried: [credential "https://firstuser@github.com/"] and not: [credential "https://firstuser@git.github.com/"] I'll give that a go. – Anton Blomström Oct 12 '20 at 00:55
  • Checked in credential manager and saw this: https://prnt.sc/uxf020 looks like gitlab is separating it, but github does not. – Anton Blomström Oct 12 '20 at 01:04
  • Yeah, I think I'll just stick to ssh. Thank you for the help though! – Anton Blomström Oct 12 '20 at 01:42

0 Answers0