|
|
|
|
|
by 3np
1765 days ago
|
|
So one thing you can do is put the following in your ~/.gitconfig: [includeIf "gitdir:/home/john/corp/**"]
path = .gitconfig-corp
And then ~/.gitconfig-corp: [user]
email = john@example.com
name = John Doe
[url "git@github.com-corp"]
insteadOf = git@github.com
Now all repos under the path /home/john/corp/ will use that config. Then you can put a new host in your SSH config: Host github.com-corp
HostName github.com
User git
IdentityFile /home/john/.ssh/corp_github
This way you can have different e-mail address and name in your commit messages as well.Due to the nature of git you can't scope it via GH URL (you can have many remotes in the same local repo). Though you can still manually rewrite when you add a remote with just the SSH config change, e.g. git clone git@github.com-corp:corp/foobar.git
|
|