First we need to update the config file with below configuration
vi ~/.ssh/config
Host gitaccountuser1
HostName github.com
User WORK_GITHUB_USERNAME
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_work_rsa
IdentitiesOnly yes
Host gitaccountuser2
HostName github.com
User PERSONAL_GITHUB_USERNAME
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_personal_rsa
IdentitiesOnly yes
we need to update the URL before we do commits and push to specific account, since we have already configure our github config file as above.
Following is the url to set for gitaccountuser1
git remote set-url origin git@gitaccountuser1:WORK_GITHUB_USERNAME/wp-plugin-customblocks.git
Following is the url to set for gitaccountuser2
git remote set-url origin git@gitaccountuser1:WORK_GITHUB_USERNAME/wp-plugin-customblocks.git
Now you should be able to push or pull from and to desired repository.