【问题标题】:How to push to a remote git branch on Gitlab?如何推送到 Gitlab 上的远程 git 分支?
【发布时间】:2018-09-07 12:00:36
【问题描述】:

我在 GiLab 上有这个 repo:

https://gitlab.com/testrepo/api.git

这个 repo 上有一个名为 testing 的分支。如何推送到此 repo 的 testing 分支?

如果我这样做:

git push origin master

它会把我的主人推到可能是回购的主人。

【问题讨论】:

  • 你目前在与master不同的分支吗?

标签: git gitlab git-push


【解决方案1】:

你可以使用命令:

git push origin <your_local_branch>:<remote_branch>

推送 git 中的任何分支。在您的示例中,这相当于运行:

git push origin master:testing

【讨论】:

    【解决方案2】:

    如果你在 git 中推送任何分支,你也可以试试这个

    如果基本没有任何问题,请创建一个新分支并通过 git checkout branch_name 转到该分支并在代码中进行所需的更改,然后添加 ., commit 并将本地更改推送到下面的 git 分支使用命令。它应该可以工作。

    $ git push --set-upstream origin Name_of_the_branch

    【讨论】:

      【解决方案3】:
      git push origin
      

      为我工作。但请确保您在远程跟踪分支(起源/测试)上。

      要移动到远程跟踪分支,首先确保你这样做

      git remote set-url origin https://gitlab.com/testrepo/api.git
      git fetch origin
      git checkout "testing" "origin/testing"
      

      【讨论】:

        猜你喜欢
        • 2011-09-10
        • 2016-07-08
        • 2012-07-25
        • 1970-01-01
        • 1970-01-01
        • 2020-09-16
        • 2015-08-14
        • 2014-02-04
        • 2020-12-01
        相关资源
        最近更新 更多