I've added two ssh config in ~/.ssh/config
:
Host account1
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile /home/USER/.ssh/account2_ssh
Host account2
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile /home/USER/.ssh/account1_ssh
What I am understanding is that with git clone git@account1:Account1/app.git
the account1's ssh key will be used for authentication. Hence, account1 will be the author of that commit, which is where i am facing the when that account2
is becoming the author of that commit instead of account1
.
I am expecting the author of that commit to be the one with whose ssh config Host setting the repo was initialized. I am also confused about who owns repo when we initialize the git locally using git init
.
First time asking a question here, Thank you!
There is no relationship between the ssh key/authentication and the commit author.
The author is set by the git setting git config user.name "John Doe"
You can use differnet settings for different project or use automatic config settings, described here Is it possible to have different Git configuration for different projects?