【问题标题】:Pushing repo to remote repository (GitHub)将 repo 推送到远程存储库 (GitHub)
【发布时间】:2016-08-09 20:40:21
【问题描述】:

我是 Git/GitHub 的新手。试图将我的文件推送到我设置的新仓库,但它不起作用。这是我的过程:

  1. 在 GitHub 上设置存储库。
  2. 在 repo 上初始化远程。 git remote add origiN <URL>
  3. 检查没问题。 git remote -v

这似乎都在按计划进行,终端机返回

origiN  <URL> (fetch)
origiN  <URL> (push)

...正如预期的那样。

然后,当我运行 git push 时,我得到:

fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

...但我以为我已经配置了远程存储库?

我错过了什么?

【问题讨论】:

    标签: git github terminal push


    【解决方案1】:

    psydroyd 在我打字时回答了,但这里稍微详细一点:

    一个存储库可以有多个远程。您可以通过运行显式推送到远程:

    git push <remote> <branch>
    

    但如果您希望 git push 在没有任何附加参数的情况下工作,您可以使用 --set-upstream 选项,也就是 -u,如下所示:

    git push -u origin master
    

    这会设置您的本地分支来跟踪远程master 分支。在此之后,您可以运行:

    git push
    

    【讨论】:

    • 谢谢!很高兴解释这个过程。
    【解决方案2】:

    git push -u origin master

    那么你可以git push

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-10
      • 2012-04-28
      • 2021-06-07
      • 1970-01-01
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 2021-06-11
      相关资源
      最近更新 更多