[英]How to squash my git branch commits into the same branch without rebasing?
[英]Git rebasing (squash) after creating new branch
假設我的提交歷史如下:
a -- b -- c <-- Branch1
\
d -- e <-- Branch2
現在我簽出到branch1,並將b
和c
提交到x中。
我期望這樣的事情會發生。
a -- x <-- Branch1
\
d -- e <-- Branch2
但是在Branch1上運行git log時,它顯示:
a -- x
在Branch2上運行git log時,它顯示:
a -- b -- c -- d -- e
現在,即使我簽出到branch2並壓扁b
, c
,它也不會生成x
而是其他一些提交哈希。
所以我的問題是,如何正確壓縮這2個提交,使其反映在所有分支中?
另外,一旦完成該如何解決?
現在我簽出到branch1,並將b和c提交到x中。
之后,您仍然在Branch1
執行以下操作
git checkout Branch2
git rebase -
重要說明,請確保在執行git rebase -
之前git rebase -
您位於需要重新設置基准的分支上。 在這種情況下,它是Branch1
。 如果您更改了分支機構,為什么要先回到Branch1
,如下所示:
git checkout Branch1
git checkout Branch2
git rebase -
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.