Recently started using Git, and a new GitHub account was created today, the submission is always said that the first account does not have permissions, and then found that git push needs to differentiate the GitHub account, is now recorded solution:
1. Create SSH KEY$ ssh-keygen -t rsa -C "[email protected]",根据提示输入文件名,如id_rsa_two,粘贴复制到github的SSH
2. See if the config file exists under user ~/.ssh, if it does not exist using the command Touch Config, then configure config
#github Server One
Host GitHub
Hostname github.com
User git
Identityfile ~/.ssh/id_rsa
#github Server
Host Github_two
Hostname github.com
User git
Identityfile ~/.ssh/id_rsa_two
3. Test configuration, the small key icon on GitHub SSH will turn green after successful test
ssh
-T [email protected]_two
#如果配置正确会提示
Hi your git account two
in
github ! You‘ve successfully authenticated, but GitHub does not provide shell access.
4.clone Project to Local
Original operation:git clone [email protected]:yourAccount
/xxx
.git;
现改为:git clone [email protected]_two.com:yourAccount
/xxx
.git
Use multiple git accounts on a single computer