【问题标题】:Squashing and merging from already squashed branch从已经被压扁的分支中压扁和合并
【发布时间】:2022-12-11 06:41:24
【问题描述】:

我有 5 个 git 提交,我已经压缩并合并了它们。但是我发现我需要将其他一些东西推送到同一个分支(创建另一个分支很麻烦)。所以我将另外两个提交推送到同一个分支并尝试在之前压缩的 ALL Tests 之上再次压缩它们。我怎么做 ?

【问题讨论】:

    标签: git


    【解决方案1】:

    只需重新设置它们:

    # first, rebase
    git rebase main~2 main --onto origin/main
    # now squash
    git reset --soft HEAD~2
    git commit -m "Whatever comment is appropriate"
    

    现在 main 是在 origin/main 之上的单一修订版

    或者,基于 UI 的方式,也有 rebase,但是是交互式的

    git rebase -i main~2 main --onto origin/main
    

    您将获得 2 个提交的列表,将第一个保留为 pick,将第二个设置为 squash,保存并退出....您将获得一个 UI,您必须在其中设置内容单身的commit 这将是您想要的压缩提交。设置一些适当的东西,保存并退出,你就完成了。

    【讨论】:

      猜你喜欢
      • 2015-01-15
      • 2014-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 2021-06-24
      • 1970-01-01
      相关资源
      最近更新 更多