赞
踩
使用win10的git bash生成ssh key:$ ssh-keygen -t rsa -C "jimmyMall@xxxe.com"
需要把公钥放到github自己账号下,过程略。
本过程在win10和Ubuntu上测试通过。
$ cat ~/.ssh/config
# github1
Host mio
HostName github.com
User miostudio
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github 2
Host eve
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
使用了 已有rsa文件。
说明:
$ ssh -T git@mio
Enter passphrase for key '/c/Users/admin/.ssh/gitee_id_rsa':
Hi miostudio! You've successfully authenticated, but GitHub does not provide shell access.
$ git remote -v
origin https://github.com/miostudio/vue_learn.git (fetch)
origin https://github.com/miostudio/vue_learn.git (push)
修改新地址:
$ git remote set-url origin git@mio:MioStudio/vue_learn.git
$ git remote -v
origin git@mio:MioStudio/vue_learn.git (fetch)
origin git@mio:MioStudio/vue_learn.git (push)
注意,修改的新地址中@前是固定的,@后是config中定义的第一行Host。冒号后面是用户名和仓库名,最后用.git结尾。
一个电脑只需要配置一次配置文件。
一个仓库只需要修改一次路径。
后面就正常的推送了,命令行或图形界面都可以。
$ git push origin master
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。