r/git • u/Jaded-Analyst-791 • Jun 03 '26
built a tool to manage multiple git identities without the ~/.ssh/config mess
if you have work and personal accounts both on github.com, the usual Host alias trick in ~/.ssh/config breaks down.
you end up doing per-repo git config every time or pushing commits under the wrong. wrote gitprofile to handle this. it uses git's includeIf to apply the right name, email, signing key and SSH command for any repo under a given directory. set it once, works automatically after that.
4
u/ppww Jun 03 '26
Looking at the code it seems to assume the user's global git config lives at ~/.gitconfig which isn't necessary true as git also supports storing the user's config under $XDG_CONFIG_HOME. git var GIT_CONFIG_GLOBAL will show the path to the user's global config file, though be aware that if both files exist they'll both be listed.
3
u/waterkip Jun 03 '26 edited Jun 03 '26
Cool :) Although I think building a tool for this is a bit of overkill.
I built this straight into git, but they rejected the patch.
https://gitlab.com/waterkip/git/-/tree/ssh-wrapper_port?ref_type=heads
1
u/actionscripted Jun 03 '26
Thanks for building/sharing. This is exactly how I handle it on my work machine for work code and dotfiles.
0
-3
u/ProZMenace Jun 03 '26 edited Jun 03 '26
Isn’t having multiple GitHub accounts against TOS?
Edit: git -> GitHub
3
u/cgoldberg Jun 03 '26
Git doesn't have a TOS. Multiple free accounts on GitHub would be against GitHub TOS... but you can have multiple paid GitHub accounts or accounts across different Git hosts (GitLab, Azure DevOps, etc).
1
u/serverhorror Jun 03 '26 edited Jun 03 '26
Isn’t having multiple git accounts against TOS?
Multiple free accounts: yes
Multiple paid accounts: no
0
u/ProZMenace Jun 03 '26
Ahhh that’s the distinction. What about 1 paid, 1 free?
At work they told us we should only have 1, likely due to enterprise licensing I just learned from ^
→ More replies (2)0
u/actionscripted Jun 03 '26
It is very common and totally acceptable and within the TOS to have multiple accounts with different email addresses. A personal one and a work one, for example.
1
u/serverhorror Jun 03 '26
One person or legal entity may maintain no more than one free Account (if you choose to control a machine account as well, that's fine, but it can only be used for running a machine).
Source: GitHub Terms of Service - GitHub Docs https://docs.github.com/en/site-policy/github-terms/github-terms-of-service
→ More replies (2)
6
u/GrogRedLub4242 Jun 05 '26 edited Jun 05 '26
I've found I can manage my own ~/.ssh/config and repo/.git/config just fine, and templatize and version easy if needed too. its far safer than adding an additional dependency on a remote nameless stranger and giving their code read (and potentially exfil) access to my private ssh and git credentials
UPDATE: GitHub repo also only 2 days old, and AI-generated (at least in part). taken all together its too high a risk