【问题标题】:'git remote add' doesn't create repo [duplicate]'git remote add' 不创建 repo [重复]
【发布时间】:2021-03-01 12:42:57
【问题描述】:

我想从我的 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)

所以似乎已经创建了 repo。但是我在我的 github 帐户中没有看到新的 repo。当我尝试检查遥控器(或在那里推送任何东西)时,它会引发错误:

% git remote show origin
remote: Repository not found.
fatal: repository 'https://github.com/<username>/example.git/' not found

我尝试用谷歌搜索类似的问题,但找不到答案。有谁知道我可能会错过什么?

【问题讨论】:

标签: git github git-remote


【解决方案1】:

git remote add 不会“在 github 上创建 repo”,它只会将您的本地 repo 链接到 github 上的(现有)远程 repo。

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

之后,您的常规 git 命令将起作用(pushpullremote show ...)。

【讨论】:

  • 谢谢,你是对的!
【解决方案2】:

如果你想从命令行创建一个 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-14
    • 2011-06-18
    • 2023-02-02
    • 1970-01-01
    • 2013-03-13
    • 2011-04-05
    • 2018-07-09
    • 2016-02-24
    相关资源
    最近更新 更多