简体   繁体   English

将分支从主节点迁移到主节点上的较早节点

[英]Rebase branch from master to earlyer node on master

Let's say i have the following graph: 假设我有以下图表:

   800      9ff
    v        v
----o--o--o--o--o--o <-master
              \
               o--o--o <-feature

And i want the following state after the command: 我想要命令后的以下状态:

   800      9ff
    v        v
----o--o--o--o--o--o <-master
     \
      o--o--o <-feature

So how do i rebase backwards on the same branch? 那么我如何在同一分支上向后调整呢? Could you please give an exact answer with the exact branchnames and 3-character-long hashes as specified? 您能否给出确切的答案以及指定的确切分支名称和3个字符长的哈希值?

Thank you very much. 非常感谢你。

This is what rebase --onto is for. 这就是rebase --onto的基础。 While on feature , do this: 在启用feature ,请执行以下操作:

git rebase --onto 800 9ff

That moves the branch you're on ( feature ) onto 800 from 9ff. 这会将您所在的分支( feature )从9ff移动到800。

I think the following should do what you want. 我认为以下应该做您想要的。

git checkout 800
git cherry-pick 9ff..feature
git checkout -b newfeature

the resulting graph will look like 结果图看起来像

   800      9ff
    v        v
----o--o--o--o--o--o <-master
     \        \
      \        o--o--o <-feature
       \              \
        \      (The same commit)
         \           /
          \         /
           \       /
            o--o--o <-newfeature

Deleting the feature branch and renaming the newfeature branch will get you the graph you desire. 删除feature分支并重命名newfeature分支将为您提供所需的图形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM