本地往远程仓库推送时报错
起因公司给配的电脑坏了,但是苹果的iCloud可以同步,在新电脑上一番配置后,发现本地的代码没法推到远程仓库:
做过的一些配置:
- 本地仓库的远程仓库地址
- ssh密钥对
- 在远程仓库上github/gitlab上也已经添加了本地密钥
报出以下的错误:
Please make sure you have the correct access rights
and the repository exists.
> git ls-tree -l HEAD -- /Users/username/Documents/github/docker_env/python/requirements.txt
> git show --textconv HEAD:python/requirements.txt
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
> git rev-list --left-right master...refs/remotes/origin/master
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
Warning: Failed to watch ref '/Users/username/Documents/github/docker_env/.git/refs/remotes/origin/master', is most likely packed.
> git config --get commit.template
> git ls-tree -l HEAD -- /Users/username/Documents/github/docker_env/python/requirements.txt
> git fetch
> git ls-tree -l HEAD -- /Users/username/Documents/github/docker_env/python/requirements.txt
> git show --textconv HEAD:python/requirements.txt
Host key verification failed.
fatal: Could not read from remote repository.
解决办法:
方法一:
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
方法二:
ssh -T git@gitlab.com
待确认时输入yes
参考文档:
Git SSH配置无误 但无法连接github远程仓库 “Host Key Verification Failed”