【问题标题】:Pushing local branch to remote branch in git在git中将本地分支推送到远程分支
【发布时间】:2016-10-25 21:49:21
【问题描述】:

我正在尝试将我的本地分支“选择”推送到远程分支 origin/tech。 我的头指向远程分支 origin/tech。 我正在使用以下命令

git push -u origin/tech opt

但它因错误而失败

fatal: 'origin/tech' does not appear to be a git repository
fatal: could not read from the remote repository

通过执行 git branch -r 确认远程分支 origin/tech 存在。

【问题讨论】:

  • git push to remote branch的可能重复
  • git branch -r 列出分支。如果它输出origin/tech,则意味着origin 是一个远程,而tech 是该远程上的一个分支。

标签: git


【解决方案1】:

如果分支名称不匹配或未配置远程url,可能会导致以下错误

致命:'origin/tech' 似乎不是 git 存储库

致命:无法从远程存储库中读取

  1. 分支不存在时修复:

     git push -u origin opt:tech
    
  2. 未配置远程url时:

    检查是否使用 git remote -v 添加了远程 url,如果没有,则使用以下添加远程:

     git remote add origin <remote url>
    

【讨论】:

    【解决方案2】:
    git push origin opt:tech
    

    origin 是您的遥控器名称。 opt:tech 必须理解为 local_branch:remote_branch

    【讨论】:

      【解决方案3】:

      我猜origin/tech 是远程分支,而不是远程

      git branch -r 列出分支。如果它输出origin/tech,则意味着origin 是一个远程,而tech 是该远程上的一个分支。

      所以你应该这样做

      git push -u origin opt:tech
      

      将本地分支推送到远程分支技术。

      https://git-scm.com/docs/git-push

      请特别查看页面底部的示例。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-02-22
        • 1970-01-01
        • 1970-01-01
        • 2011-09-10
        • 2016-07-08
        • 2013-06-10
        • 2018-12-22
        • 2012-07-25
        相关资源
        最近更新 更多