我想从shell添加远程存储库,但失败了。我已登录并在本地存储库中。所以我输入这个:
% git remote add origin https://github.com/<username>/example.git
% git remote -v
origin https://github.com/<username>/example.git (fetch)
origin https://github.com/<username>/example.git (push)
因此,回购似乎已经创建。但我在github账户中没有看到新的回购。当我试图检查遥控器(或在那里推任何东西(时,它会抛出一个错误:
% git remote show origin
remote: Repository not found.
fatal: repository 'https://github.com/<username>/example.git/' not found
我试着在谷歌上搜索类似的问题,但找不到答案。有人知道我可能遗漏了什么吗?
git remote add
不"在github上创建回购";,它只将您的本地回购链接到github上的(现有的(远程回购。
如果github上不存在example.git
,则需要首先创建它(例如:通过github的网站创建一个空的example
repo(。
之后,您的常规git命令将起作用(push
、pull
、remote show
…(
如果您想从命令行创建repo,可以使用GitHub CLI。
> gh repo create
Usage: gh repo create [<name>] [flags]
Flags:
-y, --confirm Confirm the submission directly
-d, --description string Description of repository
--enable-issues Enable issues in the new repository (default true)
--enable-wiki Enable wiki in the new repository (default true)
-h, --homepage string Repository home page URL
--internal Make the new repository internal
--private Make the new repository private
--public Make the new repository public
-t, --team string The name of the organization team to be granted access
-p, --template string Make the new repository based on a template repository