Organizing multiple Git identities
garrit.xyz
Organizing multiple Git identities
1–10 of 92 posts
Re: Organizing multiple Git identities
#2 [user]
name = "My Name"
useConfigOnly = true
Then, the first time you commit in each repo, you'll get an "Author Identity Unknown" message. Then just run `git config --local user.email hello@example.com` to set the config for that repo.Re: Organizing multiple Git identities
#3 Host github-client1
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa-client1
Host github-client2
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa-client2
Then clone using `git clone git@github-client1:username/repo.git` Is there a better way?Re: Organizing multiple Git identities
#4How do people handle multiple git identities with github+ssh? Since you always log in as the `git` user, you can't reuse keys. I end up with an ~/.ssh/config like: Host github-client1 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client1 Host github-client2 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client2 Then clone using `git clone git@github-client1:username/repo.git` Is there a better way?
If you wanted to have it all in your git config, you could set core.sshCommand to "ssh -i ~/.ssh/id_rsa-client", maybe combined with includeIf as in the article (since it's a glob match, you could match on the github org name).
Re: Organizing multiple Git identities
#5I have the email address problem, but that's the only paramter that needs to vary. I use the simplest way of handling this, which is this in my .config/git/config: [user] name = "My Name" useConfigOnly = true Then, the first time you commit in each repo, you'll get an "Author Identity Unknown" message. Then just run `git config --local user.email hello@example.com` to set the config for that repo.
Re: Organizing multiple Git identities
#6How do people handle multiple git identities with github+ssh? Since you always log in as the `git` user, you can't reuse keys. I end up with an ~/.ssh/config like: Host github-client1 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client1 Host github-client2 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client2 Then clone using `git clone git@github-client1:username/repo.git` Is there a better way?
put this in your ~/.gitconfig-personal
[core]
sshCommand = "ssh -i ~/.ssh/github_personal_ed25519"
and this in your ~/.gitconfig-work [core]
sshCommand = "ssh -i ~/.ssh/github_work_ed25519"Re: Organizing multiple Git identities
#7How do people handle multiple git identities with github+ssh? Since you always log in as the `git` user, you can't reuse keys. I end up with an ~/.ssh/config like: Host github-client1 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client1 Host github-client2 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client2 Then clone using `git clone git@github-client1:username/repo.git` Is there a better way?
Re: Organizing multiple Git identities
#8How do people handle multiple git identities with github+ssh? Since you always log in as the `git` user, you can't reuse keys. I end up with an ~/.ssh/config like: Host github-client1 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client1 Host github-client2 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client2 Then clone using `git clone git@github-client1:username/repo.git` Is there a better way?
; .config/git/id_example
[user]
name = "git"
email = "git@localhost"
[core]
sshCommand = "ssh -i ~/.ssh/id_example"
Configurable per repo with many identities. Add a global alias to engage any identity at any time.git config --global alias.as-example '!git -c include.path=~/.config/git/id_example'
git as-example commit -m "my commit message as example"Re: Organizing multiple Git identities
#9How do people handle multiple git identities with github+ssh? Since you always log in as the `git` user, you can't reuse keys. I end up with an ~/.ssh/config like: Host github-client1 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client1 Host github-client2 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client2 Then clone using `git clone git@github-client1:username/repo.git` Is there a better way?
I used to do it that way. Recently learned this approach put this in your ~/.gitconfig-personal [core] sshCommand = "ssh -i ~/.ssh/github_personal_ed25519" and this in your ~/.gitconfig-work [core] sshCommand = "ssh -i ~/.ssh/github_work_ed25519"
Re: Organizing multiple Git identities
#10How do people handle multiple git identities with github+ssh? Since you always log in as the `git` user, you can't reuse keys. I end up with an ~/.ssh/config like: Host github-client1 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client1 Host github-client2 Hostname github.com User git IdentityFile ~/.ssh/id_rsa-client2 Then clone using `git clone git@github-client1:username/repo.git` Is there a better way?