我發現了 Git 的fixup/autosquash特性并想嘗試一下。不幸的是,我在壓縮一些fixup提交時遇到了問題。
這是我當前運行時的 Git 歷史記錄git log --oneline -n 4:
95686a33 (HEAD -> feature/ABC-1234-My-Feature, origin/feature/ABC-1234-My-Feature) fixup! feat: implement my feature
ac56a2ee fixup! feat: implement my feature
de904aa3 fixup! feat: implement my feature
cc3a205b feat: implement my feature
現在我正在運行git rebase -i --autosquash cc3a205b,編輯器打開時顯示以下內容:
pick de904aa3 fixup! feat: implement my feature
pick ac56a2ee fixup! feat: implement my feature
pick 95686a33 fixup! feat: implement my feature
# Rebase cc3a205b..95686a33 onto cc3a205b (3 commands)
我在不做任何更改的情況下關閉編輯器,導致以下輸出:
Successfully rebased and updated refs/heads/feature/ABC-1234-My-Feature.
再次執行git log --oneline -n 4時,3 次fixup提交仍然存在。
我希望歷史記錄只包含feat: implement my feature具有新 Git 提交 ID 的單個提交,但不包含fixup提交。
我做錯了什么還是我有錯誤的期望?
運行git --version回傳git version 2.38.1.windows.1,所以我使用的是最新版本。
uj5u.com熱心網友回復:
問題是您的選擇串列不包含您要將修正合并到的提交:
pick de904aa3 fixup! feat: implement my feature
pick ac56a2ee fixup! feat: implement my feature
pick 95686a33 fixup! feat: implement my feature
請注意,您的feat: implment my feature提交不會顯示在那里。否則,Git 無法將這些識別為修復提交,并且它們無法合并。
您需要改為針對cc3a205b^(的父級cc3a205b)進行變基:
git rebase -i --autosquash cc3a205b^
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/534328.html
標籤:混帐
