【问题标题】:Push local commits on master branch to new remote branch将主分支上的本地提交推送到新的远程分支
【发布时间】:2015-07-24 02:57:44
【问题描述】:

我在 master 分支上有本地提交,但是(由于不可预见的外部原因)我现在无法将更改推送到 master,而是需要将它们推送到新的远程分支(可以稍后合并回 master )。

我该如何(安全地)做到这一点?

【问题讨论】:

  • 你试过git push <REMOTENAME> <BRANCHNAME>了吗?
  • @AlexPan 我什么都没试过,因为我对 git 的经验是你可以很容易地把事情搞砸。
  • Push commits to another branch 的可能重复项

标签: git branch


【解决方案1】:

创建一个新分支:

git checkout -b myNewBranch

推送回购:

git push

【讨论】:

    【解决方案2】:

    不创建新的本地分支的最简单方法是: 假设您在分支 test localy 上,并希望将其推送到名为 test-remote 的新分支

    $ git push origin test:test-remote

    【讨论】:

      猜你喜欢
      • 2011-03-13
      • 1970-01-01
      • 2020-12-13
      • 2016-10-25
      • 2015-04-02
      • 2012-03-30
      • 2018-10-02
      • 2016-02-22
      • 2021-07-14
      相关资源
      最近更新 更多