cd ~/.ssh
1、如果没有id_rsa.xxx文件,先生成一个,有则跳过:
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/macbook/.ssh/id_rsa): /Users/macbook/.ssh/id_rsa.xxx
把生成的id_rsa.xxx.pub复制到git仓库的ssh keys
2、查看是否有config文件,如果没有则新建:
touch config
3、打开config文件可以设置多个git账号对应的ssh key:
Host github.com
HostName github.com
User xxxxxx@qq.com
IdentityFile ~/.ssh/id_rsa
Host git.xxx.com
HostName git.xxx.com
User xxx
IdentityFile ~/.ssh/id_rsa.xxx
4、进入当前项目目录,查看当前git地址:
git remote -v
如果用的http,换成ssh地址:
git remote remove origin
git remote add origin 远程地址(ssh)
git remote -v
2021.5.26:
一直推送远程不成功,提示:![]()
// 把git地址换成http的就可以了,原因还不清楚
git remote rm origin
git remote add origin http://git.dev.mart.com/opscenter/ark-web.git







网友评论