小编典典

Git/Git Extension 中的“squash”和“fixup”有什么区别?

git

我已经使用Git Extensions有一段时间了(太棒了!),但我还没有找到以下问题的简单答案:

有时,在输入提交信息时,会出现拼写错误。我的朋友向我展示了如何通过以下方式修复它(在 Git 扩展中):

右键单击提交 > 高级 > 修复提交

在此处输入图像描述

然后我只需选中“修改”框并重写我的信息,瞧!我的提交信息是固定的。

然而,另一个选项“Squash commit”......我一直想知道它的作用是什么?!

我的问题是:

有人能简单地解释一下Git/Git 扩展中的Squash 提交Fixup 提交之间的确切区别是什么吗?他们看起来有点……和我“相似”在此处输入图像描述 在此处输入图像描述


阅读 239

收藏
2022-05-26

共1个答案

小编典典

我不知道 Git Extensions 专门用它做什么,但git rebase可以选择使用 squash 自动压缩或修复提交!或修复!前缀,分别:

   --autosquash, --no-autosquash
       When the commit log message begins with "squash! ..." (or "fixup!
       ..."), and there is a commit whose title begins with the same ...,
       automatically modify the todo list of rebase -i so that the commit
       marked for squashing comes right after the commit to be modified,
       and change the action of the moved commit from pick to squash (or
       fixup).

squash 和 fixup 的区别在于,在 rebase 期间,squash操作会提示您合并原始和 squash 提交的消息,而fixup操作会保留原始消息并丢弃来自 fixup 提交的消息。

2022-05-26