无法推送到我的 github 私有存储库
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 syntax,以确保使用了您的 ~/.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
如“Why doesn't the ssh command follow RFC on URI?”中所述,两者之间存在差异:
ssh://[user@]host.xz[:port]/path/to/repo.git
vs.
user@host.xz:/path/to/repo.git
只有后一种语法 user@host.xz:
使用 ssh config file.
When SSH was originally developed, it was developed as a more secure, drop-in replacement for the earlier RSH/rlogin suite of tools.
参见“History of the SSH protocol”。
OpenSSH (1999) predates URI (finalized in RFC 3986, 2005 年 1 月发表)
If the host portion was allowed to be on the form host:port
, this would create a potential ambiguity: does jdoe@host.example.com:2222
refer to ~jdoe/2222
on host.example.com
when connecting on the standard port, or does it refer to no file at all (or worse, ~jdoe
) on host.example.com
when connecting over port 2222?
在我学习 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 syntax,以确保使用了您的 ~/.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
如“Why doesn't the ssh command follow RFC on URI?”中所述,两者之间存在差异:
ssh://[user@]host.xz[:port]/path/to/repo.git
vs.
user@host.xz:/path/to/repo.git
只有后一种语法 user@host.xz:
使用 ssh config file.
When SSH was originally developed, it was developed as a more secure, drop-in replacement for the earlier RSH/rlogin suite of tools.
参见“History of the SSH protocol”。
OpenSSH (1999) predates URI (finalized in RFC 3986, 2005 年 1 月发表)
If the host portion was allowed to be on the form
host:port
, this would create a potential ambiguity: doesjdoe@host.example.com:2222
refer to~jdoe/2222
onhost.example.com
when connecting on the standard port, or does it refer to no file at all (or worse,~jdoe
) onhost.example.com
when connecting over port 2222?