使用 "fixup!" 或 "squash!" 之间有什么真正的区别吗?
Are there any real differences between using "fixup!" or "squash!"?
我一直在阅读关于 commit and rebase, but I still don't understand the difference between using fixup!
or squash!
as a prefix for the commit message when doing a rebase --autosquash
. I believe I understand what fixup!
does in terms of fixing previous commits 的 git 文档,但我没有看到一个很好的例子,其中使用了 squash!
。任何人都可以澄清两者之间的区别并给出一些不同使用它们的上下文吗?提前致谢!
正如我在“Trimming Git Commits/Squashing Git History”中所说明的那样,总结一下:
with the fixup! directive, you could keep that squashing "invisible" in the commit message, while still benefiting from the automatic commit reordering with the --autosquash
option
作为 Op Dash 评论:
Using squash!
will guarantee that the squashing operation is recorded in the history, which is unlike fixup!
where the squash operation is invisible for a more "cleaner" approach.
另一个区别,before Git 2.16.x/2.17(2018 年第 1 季度),是你不能合并“git commit --fixup
" 附加提交 message.
现在不再是这种情况了。
参见 commit 30884c9 (22 Dec 2017) by Ævar Arnfjörð Bjarmason (avar
)。
帮助:Eric Sunshine (sunshineco
).
(由 Ævar Arnfjörð Bjarmason -- avar
-- in commit 30884c9 合并,2017 年 12 月 22 日)
commit
: add support for --fixup <commit> -m"<extra message>"
Add support for supplying the -m
option with --fixup
.
Doing so has errored out ("Option -m
cannot be
combined") ever since --fixup
was introduced.
Before this, the only way to amend the fixup message while committing was to use --edit
and amend it in the editor.
The use-case for this feature is one of:
Leaving a quick note to self when creating a --fixup
commit when
it's not self-evident why the commit should be squashed without a
note into another one.
(Ab)using the --fixup
feature to "fix up" commits that have already
been pushed to a branch that doesn't allow non-fast-forwards,
i.e. just noting "this should have been part of that other commit
",
and if the history ever got rewritten in the future the two should
be combined.
In such a case you might want to leave a small message,
e.g. "forgot this part, which broke XYZ
".
请注意,在 Git 2.17 (Q2 2018) 之前,“git commit --fixup
”不允许同时使用“-m<message>
”选项;允许它用更多文本注释结果提交。
见commit 30884c9, commit f55e84f (22 Dec 2017) by Ævar Arnfjörð Bjarmason (avar
)。
帮助:Eric Sunshine (sunshineco
).
(由 Junio C Hamano -- gitster
-- in commit c1ab3b8 合并,2018 年 2 月 27 日)
commit
: add support for --fixup <commit> -m"<extra message>"
Add support for supplying the -m
option with --fixup
. Doing so has
errored out ever since --fixup
was introduced. Before this, the only
way to amend the fixup message while committing was to use --edit
and
amend it in the editor.
此功能的用例是以下之一:
Leaving a quick note to self when creating a --fixup
commit when
it's not self-evident why the commit should be squashed without a
note into another one.
(Ab)using the --fixup
feature to "fix up" commits that have already
been pushed to a branch that doesn't allow non-fast-forwards,
i.e. just noting "this should have been part of that other commit",
and if the history ever got rewritten in the future the two should
be combined.
In such a case you might want to leave a small message,
e.g. "forgot this part, which broke XYZ".
With this, --fixup <commit> -m"More" -m"Details"
will result in a
commit message like:
!fixup <subject of <commit>>
More
Details
When the --fixup
option was initially added the "Option -m
cannot be
combined" error was expanded from -c
, -C
and -F
to also include
--fixup
(commit d71b8ba, "commit: --fixup option for use with rebase --autosquash
", 2010-11-02, Git 1.7.4-rc0)).
我一直在阅读关于 commit and rebase, but I still don't understand the difference between using fixup!
or squash!
as a prefix for the commit message when doing a rebase --autosquash
. I believe I understand what fixup!
does in terms of fixing previous commits 的 git 文档,但我没有看到一个很好的例子,其中使用了 squash!
。任何人都可以澄清两者之间的区别并给出一些不同使用它们的上下文吗?提前致谢!
正如我在“Trimming Git Commits/Squashing Git History”中所说明的那样,总结一下:
with the fixup! directive, you could keep that squashing "invisible" in the commit message, while still benefiting from the automatic commit reordering with the
--autosquash
option
作为 Op Dash 评论:
Using
squash!
will guarantee that the squashing operation is recorded in the history, which is unlikefixup!
where the squash operation is invisible for a more "cleaner" approach.
另一个区别,before Git 2.16.x/2.17(2018 年第 1 季度),是你不能合并“git commit --fixup
" 附加提交 message.
现在不再是这种情况了。
参见 commit 30884c9 (22 Dec 2017) by Ævar Arnfjörð Bjarmason (avar
)。
帮助:Eric Sunshine (sunshineco
).
(由 Ævar Arnfjörð Bjarmason -- avar
-- in commit 30884c9 合并,2017 年 12 月 22 日)
commit
: add support for--fixup <commit> -m"<extra message>"
Add support for supplying the
-m
option with--fixup
.
Doing so has errored out ("Option-m
cannot be combined") ever since--fixup
was introduced.
Before this, the only way to amend the fixup message while committing was to use--edit
and amend it in the editor.The use-case for this feature is one of:
Leaving a quick note to self when creating a
--fixup
commit when it's not self-evident why the commit should be squashed without a note into another one.(Ab)using the
--fixup
feature to "fix up" commits that have already been pushed to a branch that doesn't allow non-fast-forwards,
i.e. just noting "this should have been part of that other commit
", and if the history ever got rewritten in the future the two should be combined.In such a case you might want to leave a small message,
e.g. "forgot this part, which broke XYZ
".
请注意,在 Git 2.17 (Q2 2018) 之前,“git commit --fixup
”不允许同时使用“-m<message>
”选项;允许它用更多文本注释结果提交。
见commit 30884c9, commit f55e84f (22 Dec 2017) by Ævar Arnfjörð Bjarmason (avar
)。
帮助:Eric Sunshine (sunshineco
).
(由 Junio C Hamano -- gitster
-- in commit c1ab3b8 合并,2018 年 2 月 27 日)
commit
: add support for--fixup <commit> -m"<extra message>"
Add support for supplying the
-m
option with--fixup
. Doing so has errored out ever since--fixup
was introduced. Before this, the only way to amend the fixup message while committing was to use--edit
and amend it in the editor.
此功能的用例是以下之一:
Leaving a quick note to self when creating a
--fixup
commit when it's not self-evident why the commit should be squashed without a note into another one.(Ab)using the
--fixup
feature to "fix up" commits that have already been pushed to a branch that doesn't allow non-fast-forwards, i.e. just noting "this should have been part of that other commit", and if the history ever got rewritten in the future the two should be combined.In such a case you might want to leave a small message, e.g. "forgot this part, which broke XYZ".
With this,
--fixup <commit> -m"More" -m"Details"
will result in a commit message like:!fixup <subject of <commit>> More Details
When the
--fixup
option was initially added the "Option-m
cannot be combined" error was expanded from-c
,-C
and-F
to also include--fixup
(commit d71b8ba, "commit: --fixup option for use withrebase --autosquash
", 2010-11-02, Git 1.7.4-rc0)).