git使用:1台windows电脑,连2个git配置
git下载:https://git-scm.com/downloads
配合提交代码下载:https://tortoisegit.org/download/
git 常用命令:
git clone git pull git add . git commit -m “提交备注” (切记commit 之前 先git pull) git push origin main
我已有一个sshkey 了
widow,找到已有的.ssh文件夹打开,打开Git bash
再次执行:
ssh-keygen -t rsa -C 2186009311@qq.com -f ~/.ssh/id_rsa_two
新建文件
touch config
配置
# 配置github.com
Host github.com
HostName github.com
IdentityFile C:\\Users\\popfisher\\.ssh\\id_rsa_github
PreferredAuthentications publickey
User username1
# 配置git.oschina.net
Host git.oschina.net
HostName git.oschina.net
IdentityFile C:\\Users\\popfisher\\.ssh\\id_rsa_oschina
PreferredAuthentications publickey
User username2
示例:我这边是有ip没端口的,和github的例子,去掉#的内容即可,以ip:192.168.2.118 用户名都为“123456789@qq.com”,文件目录在“C:\\Users\\458\\.ssh”为例
# mygit Host 192.168.2.118 HostName 192.168.2.118 PreferredAuthentications publickey IdentityFile C:\\Users\\458\\.ssh\\id_rsa User 123456789@qq.com # github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile C:\\Users\\458\\.ssh\\id_rsa_two User 123456789@qq.com
网页设置新增sshkey
测试:
ssh -T git@github.com
亲测有效,很开心。。。
错误解决:
错误一:no supported authentication methods avaiable
设置,勾选远程,并配置git的ssh.exe应用并确认(注意是user下的bin,不是直接的bin下的ssh,之前我就配置了bin下的sh.exe)
错误二:error: src refspec master does not match any
分支名写错了 ,写成正确的就好了
参考链接:
https://www.cnblogs.com/hewei-blogs/p/14183160.html
https://www.cnblogs.com/godfeer/p/12214301.html
https://www.cnblogs.com/popfisher/p/5731232.html
https://jingyan.baidu.com/article/ab69b2708d09382ca7189f9b.html
https://blog.csdn.net/qq_29897369/article/details/81430380
https://blog.csdn.net/ur_eyes_/article/details/108714812