gpt4 book ai didi

git - COPY 本地提交到另一个分支

转载 作者:太空狗 更新时间:2023-10-29 13:53:08 24 4
gpt4 key购买 nike

我正在阅读 rebase 文档。 Rebase“转发端口本地提交到更新的上游头”。好的,...可以复制本地提交到上游更新吗?

这是起点:

           o---o---o---o---o  master
\
o---o---o---o---o next
\
o---o---o topic

这是我可以通过 rebase 获得的:

           o---o---o---o---o  master
| \
| o'--o'--o' topic
\
o---o---o---o---o next

这就是我想要的:

           o---o---o---o---o  master
| \
| o'--o'--o' new topic
\
o---o---o---o---o next
\
o---o---o topic

没有理由:我只是问是否可能。

最佳答案

  1. git checkout -b topic2 master

    o---o---o---o---o  master / topic2
    \
    o---o---o---o---o next
    \
    o---o---o topic
  2. git rebase --onto topic2 下一个主题

    将所有从next(不包括)到topic(包括)的提交 rebase 到topic2

     o---o---o---o---o  master
    | \
    | o'--o'--o' topic2
    \
    o---o---o---o---o next
    \
    o---o---o topic

PS:如果您已经对 topic 分支进行了 rebase

       o---o---o---o---o  master
| \
| o'--o'--o' topic
\
o---o---o---o---o next

“旧”提交并没有消失。检查 git reflog,您可以重新创建“旧”分支。

 git checkout -b old_topic <TOPIC_COMMIT_ID_BEFORE_REBASE>

关于git - COPY 本地提交到另一个分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33914731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com