【问题标题】:Did rebase of git from remote branch, after rebase, branch info is lost是否从远程分支 rebase git,rebase 后,分支信息丢失
【发布时间】:2015-05-02 12:43:42
【问题描述】:

我有一个远程分支:假设是 X 我有一面镜子或以上:假设是 Y 在 Y 中,我有另一个分支功能。

我想用 X 重新定义功能,所以尝试了以下命令: git rebase X/master Y/feature

在此之后,分支信息丢失,我无法推送任何更改。

任何指针??

【问题讨论】:

  • 你不能变基远程跟踪分支...
  • 如果 torek 的回答完全回答了您的问题,请考虑接受。

标签: git git-rebase git-remote


【解决方案1】:

正如 Jubobs 所说的 in a comment,你不能那样做。

更具体地说,如文档所述:

git rebase ... [upstream [branch]]

如果指定了 branchgit rebase 将在执行任何其他操作之前自动执行git checkout <em>branch</em>。 ...

在您的示例中,您写道:

git rebase X/master Y/feature

这里,upstreamX/masterbranchY/feature,所以变基过程从 git checkout Y/feature 开始。

如果你自己尝试一下,你会看到:

Note: checking out 'Y/feature'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

所以,git rebase 将首先让您进入“分离 HEAD”状态。然后它将使用X/master 作为新分离的 HEAD 的上游来执行通常的变基操作。

这具有明确的含义,但可能与您的意图不同(尽管我不清楚您的意图是什么)。

【讨论】:

    猜你喜欢
    • 2020-04-04
    • 2016-05-03
    • 2015-10-31
    • 2017-12-22
    • 1970-01-01
    • 2021-08-20
    • 2012-03-24
    • 1970-01-01
    • 2021-03-28
    相关资源
    最近更新 更多