简体   繁体   English

如何修复 Git 中的上层提交?

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

When rebasing in Git we usually can join (fixup, squash) several commits to bottom one, for instance, A, B, C -> A' (here B and C are newer than A).在 Git 中变基时,我们通常可以加入(修复、挤压)几个提交到底部一个,例如, A, B, C -> A' (这里 B 和 Z0D61F8370CAD114D412F80B84D 比 A.15F80B84D 更新) This is not a good practise as you see a date of beginning of work (commit A), but not it's finish (commit C).这不是一个好的做法,因为您会看到工作开始的日期(提交 A),但不是完成日期(提交 C)。 Like you made a feature on 23.09.2019, but not on 25.09.就像您在 23.09.2019 上制作了一个功能,但不是在 25.09 上。

Now we have several commits and want to fixup A, B, C to C: A, B, C, D, E -> C', D', E' .现在我们有几个提交并且想要修复 A、B、C 到 C: A, B, C, D, E -> C', D', E' How to do this?这个怎么做?

I'd proceed like this我会这样进行

# 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