保存ssh key时提示 Key is already in use
当你通过终端获得本地的ssh key,并在gitHub上的ssh配置里,输入了正确格式的key,按下保存时,提示 Key is already in use ,代表你此时保存的ssh key已经在其他的gitHub账号上保存过了。同一个key是不能给多个gitHub使用的。
- 方案1:删除另一个gitHub账号上保存的ssh key
- 在终端输入以下代码得到本地ssh绑定的gitHub账户。
ssh -T -i ~/.ssh/id_rsa git@gitHub.comssh -T -i ~/.ssh/id_rsa git@gitHub.com登录这个账户。
找到setting里的ssh模块,删除绑定的这个ssh key。
重新登录之前的gitHub账号,进行保存key操作发现可行。
- 方案2:配置同一个key给多个gitHub使用【需要折腾】
获得本地ssh key使用时提示格式错误
保存key时提示:
Key is invalid. You must supply a key in OpenSSH public key format
因为直接复制终端里的ssh key会导致格式错乱,黏贴到gitHub的时候会报错,所以这里建议通过命令直接复制到粘贴板:
clip < ~/.ssh/id_rsa.pubclip < ~/.ssh/id_rsa.pub提交代码时报错
报错:
ERROR: Permission to liang14658fox/liang14658fox.gitHub.io.git denied to liang14658foxgitHub. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.可能的原因:
- 本地ssh和gitHub所绑定的不同
使用VPN代理时出现的问题
git push报错:The current branch master has no upstream branch
git bash提示如下:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.原因:没有将本地的分支与远程仓库的分支进行关联
通过git branch查看本地分支只有master
git branchgit branch- 通过git branch -a查看远程分支,有master和remotes/origin/master两个
git branch -agit branch -a这时由于远程仓库太多,且分支较多。在默认情况下,git push时一般会上传到origin下的master分支上,然而当repository和branch过多,而又没有设置关联时,git就会产生疑问,因为它无法判断你的push目标
解决方案
- 方式一
使用git push --set-upstream origin master命令
- 方式二
使用git push -u origin master命令
liang14658fox