[英]Cannot push to my github private repository
当我正在学习git时,我在GitHub上建立了一个私有存储库。 我创建了ssh密钥并将其存储到我的GitHub帐户并在我的本地Linux机器上编辑了.ssh / config文件:
## github
Host github.com
User git
HostName github.com
IdentityFile ~/.ssh/github.key
我可以成功连接到我的GitHub帐户:
$ ssh -T github
Hi <UserName>! You've successfully authenticated, but GitHub does not provide shell access.
我在本地机器上初始化了一个git存储库,设置了用户并添加了一个远程存储库:
$ git init
$ git config user.name "UserName"
$ git config user.email "UserEmail"
$ git remote add origin ssh://github:<UserName?/<repositoryName>.git
我创建了一个README.md
文件,将其添加到git并提交它:
$ git add README.md
$ git commit -m "First commit."
现在,每当我尝试推送时,我都会收到此错误:
$ git push origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
克隆存储库是有效的,但这是我唯一能做的事情。
为什么我不能推送到我的私人存储库? 我究竟做错了什么?
请尝试使用scp语法 ,以确保使用~/.ssh/config
文件:
git remote set-url origin github:<username>/<repo>
然后再试一次。
Git本身使用的是OpenSSH版本(至少是一个带有Git for Windows的软件包)
> ssh -V
OpenSSH_7.5p1, OpenSSL 1.0.2k 26 Jan 2017
如“ 为什么ssh命令不遵循URI上的RFC? ”中所述,之间存在以下区别:
ssh://[user@]host.xz[:port]/path/to/repo.git
vs.
user@host.xz:/path/to/repo.git
只有后一种语法user@host.xz:
使用ssh配置文件 。
最初开发SSH时,它是作为早期RSH / rlogin工具套件的更安全,直接替代品而开发的。
请参阅“ SSH协议的历史记录 ”。
OpenSSH (1999)早于URI (在RFC 3986中定稿,2005年1月发布)
如果允许主机部分位于表单
host:port
,这将产生潜在的歧义:当在标准端口上连接时,~jdoe/2222
host.example.com
jdoe@host.example.com:2222
指向host.example.com
上的~jdoe/2222
,或通过端口2222连接时,它是指host.example.com
上根本没有文件(或更糟,~jdoe
)?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.