git - 如何使用压缩的提交进行 rebase

标签 git rebase

我有一个看起来像这样的东西

                6---7 (currentBranch)
               /
      3---4---5---8 (initialBranch)
     /
1---2 (master)

我将 initialBranch merge 到 master 中,所以现在 master 看起来像这样

1---2---9 where commit '9' is commits 3+4+5+8 squashed together

我的最终目标是将远程仓库中的 currentBranch rebase 看起来像

          6---7 (currentBranch)
         /
1---2---9

完成此操作需要运行哪些命令系列?

最佳答案

如果原始 initialBranchcurrentBranch 之间仍有提交“merge 基础”,即提交 5,则可以执行 rebase --onto:

git rebase --onto master 5 currentBranch

这将在当前 master 之上重播第 5 次(即第 6 次和第 7 次)之后 的任何提交。

关于git - 如何使用压缩的提交进行 rebase ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69948930/

相关文章:

git - 源树 : updating develop and master when both are way behind active branch

git - 为什么 Git 在(理论上)忽略的文件(路径)上向我建议 "changes"?

git 更改分支的起源(rebase)

git - 如何将 Git 的交互式 rebase 与仅限本地的存储库(无远程/源)一起使用?

git svn 并与私有(private)分支机构合作?

git - .gitignore 提交后

javascript - git 与 npm 有何关系? | npm 错误!使用git失败。 | Material .Angular.io

git - pull 警告: suboptimal pack - out of memory时出错

Git:如何跳到 rebase 的末尾并保留到目前为止的所有更改?

svn - 当其他团队成员只在 SVN 上工作时,在本地使用 Hg 并推送到 SVN 存储库——这可能吗?