Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
';git远程添加';不';不创建回购_Git_Github_Git Remote - Fatal编程技术网

';git远程添加';不';不创建回购

';git远程添加';不';不创建回购,git,github,git-remote,Git,Github,Git Remote,我想从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.g

我想从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)
%git远程添加来源https://github.com//example.git
%git远程-v
起源https://github.com//example.git (取回)
起源https://github.com//example.git (推)
因此,回购协议似乎已经成立。但我在我的github账户中没有看到新的回购协议。当我试图检查遥控器(或将任何东西推到遥控器上)时,它会抛出一个错误:

% git remote show origin
remote: Repository not found.
fatal: repository 'https://github.com/<username>/example.git/' not found
%git远程显示源代码
远程:未找到存储库。
致命:存储库'https://github.com//example.git/”“没有找到

我试着用谷歌搜索类似的问题,但找不到答案。有人知道我可能缺少什么吗?

git remote add没有“在github上创建回购”,它只将本地回购链接到github上的(现有)远程回购

如果github上不存在
example.git
,则需要首先创建它(例如:通过github的网站创建一个空的
example
repo)


之后,您的常规git命令将起作用(
push
pull
remote show
)。

如果要从命令行创建repo,可以使用

>gh回购创建
用法:gh repo create[][标志]
旗帜:
-y、 --直接确认提交
-d、 --存储库的描述字符串描述
--启用问题在新存储库中启用问题(默认为true)
--启用wiki在新存储库中启用wiki(默认为true)
-h、 --主页字符串存储库主页URL
--内部将新存储库设置为内部
--private将新存储库设置为私有
--public将新存储库公开
-t、 --团队字符串要授予访问权限的组织团队的名称
-p、 --模板字符串基于模板存储库创建新存储库

谢谢,你说得对!如果您正在寻找在GitHub上创建repo的方法,而不是使用他们的GUI(就像我通常喜欢的那样),请查看Hub CLI Hello并欢迎使用SO。请看一看。@konekoya
hub
已被
gh
替换为新的官方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