gpt4 book ai didi

用于迁移多个提交的 git rebase?

转载 作者:太空狗 更新时间:2023-10-29 12:54:20 24 4
gpt4 key购买 nike

我想进一步了解 git rebase

假设我有这个工作流,git rebase 在这里有用吗?如果是这样,将提交 X 迁移到 Z(假设不使用 cherry-pick)从 MASTERBRANCH.

enter image description here

最佳答案

信不信由你,你实际上是在 branch 上 rebase master !

以下是您可以用来实现此目的的命令:

git checkout master                  # checkout the master branch
git checkout -b newbranch # create new branch based on master
git rebase branch # rebase on 'branch'

请记住,我创建了一个名为 newbranch 的新分支,它将以您想要的方式显示。您想对原始 分支 做什么由您决定。现在 newbranch 看起来像这样:

A--B--C--D--X--Y--Z

一个更典型的工作流程是将 master 中的新更改带到 branch 中,方法是将后者重新设置为前者的基础,即:

git checkout branch
git rebase master

这将使 branch 看起来像这样:

A--X--Y--Z--B--C--D

关于用于迁移多个提交的 git rebase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31239796/

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