首页 > 解决方案 > 我通过我的 SSH 密钥在 Github 上成功进行了身份验证,但是如何克隆/推送/拉取(私有)存储库?

问题描述

我按照 Github 上关于如何注册我的 SSH 密钥的官方解释,根据他们的文档,一切都应该工作:

$ ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

不幸的是,这并没有说明如何克隆/推送/拉取存储库,并且在任何地方都没有相关文档。

例如,刚刚创建了一个新的(私有)存储库,我复制了存储库地址并尝试了:

git clone https://github.com/myusername/mynewrepository.git

我只收到

Cloning into 'mynewrepository'...
Username for 'https://github.com': myusername
Password for 'https://myusername@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/myusername/mynewrepository.git/'

问题:在 Github 上的(私有)存储库上执行 Git 操作的确切命令是什么?

标签: github

解决方案


如果您想使用 SSH 密钥进行 git 操作,请使用:

git clone git@github.com:myusername/mynewrepository.git

...如文档中所述。SSH 密钥不会影响任何基于 HTTPS 的连接


推荐阅读