簡體   English   中英

如何修復 Git 中的上層提交?

[英]How to fixup commits to upper in Git?

在 Git 中變基時,我們通常可以加入(修復、擠壓)幾個提交到底部一個,例如, A, B, C -> A' (這里 B 和 Z0D61F8370CAD114D412F80B84D 比 A.15F80B84D 更新) 這不是一個好的做法,因為您會看到工作開始的日期(提交 A),但不是完成日期(提交 C)。 就像您在 23.09.2019 上制作了一個功能,但不是在 25.09 上。

現在我們有幾個提交並且想要修復 A、B、C 到 C: A, B, C, D, E -> C', D', E' 這個怎么做?

我會這樣進行

# We first point to C
git checkout C

# Then we "unpack" changes between A and C into the working tree
git reset --soft A

# Let's now create commit C'
git commit -m "Message for C' (so A,B and C)"

# and finally we just have to bring back copies of D and E
git cherry-pick D E

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM