简体   繁体   English

Git Rebase中修正和删除提交之间的区别

[英]Differences Between Fixup and Removing a Commit in Git Rebase

When using interactive rebase, I don't understand the difference between Fixup-ing a commit into the previous one, and simply deleting all the other commits from the list. 当使用交互式rebase时,我不了解将一个提交修正为上一个提交与从列表中删除所有其他提交之间的区别。

As far as I can tell, since git commits take a snapshot of the entire repository for each commit, fixup doesn't accomplish anything more than creating merge conflicts that I have to resolve. 据我所知,由于git commit会为每个提交拍摄整个存储库的快照,因此fixup除了创建我必须解决的合并冲突之外,所做的工作不多。

From the test repository I created and ran test commands on, I get the same results from using fixup, and deleting those commits entirely and only using the last one. 从创建和运行测试命令的测试存储库中,使用fixup并完全删除这些提交(仅使用最后一个提交)可获得相同的结果。 What's the point of fixup? 修复的重点是什么?

If you've for example two commits on the same part of the code (the second one being a bug fix on the previous committed code), keeping only the second commit will not work because the second commit wouldn't find the base code on which the modifications need to be applied. 例如,如果您对代码的同一部分进行了两次提交(第二次提交是对先前提交的代码的错误修复),则仅保留第二次提交将不起作用,因为第二次提交无法在其上找到基本代码需要进行哪些修改。

In order to keep only one commit for both modifications, the second commit needs to be fixed-up (merged) to the first one. 为了只为两个修改保留一个提交,第二个提交需要固定(合并)到第一个提交。

Source (in french): git merge and rebase 来源(法语): git merge和rebase

Hope that this answer will help you. 希望这个答案对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM