问题描述:
Git生成密钥后将密钥配置到Github上,但是每次提交代码的时候还是要输入用户名和密码。操作步骤很是麻烦。
问题引入:
- 因为用的是https而不是ssh,更新origin为ssh格式即可。
https的格式为:https://github.com/用户名/仓库名.git
ssh的格式为:git@github.com:用户名/仓库名.git
解决方法:
git remote remove origin
git remote add origin git@github.com:用户名/仓库名.git
新问题:
此时提交代码可以不用重复输入用户名与密码了,但是问题来了:当你拉代码的时候,会报如下的错误:

即不知道当前pull的是哪个之分的代码。
解决方法,截图中已给出提示(方法二选一):
1、拉取代码的时候设置路径以及分支
git pull origin master

2、重新设置 track branch
git branch --set-upstream-to=origin/master master


网友评论