These commands create a new commit, which targets an existing commit, from the staged changes and/or using a new commit message. Any commit that is reachable from HEAD, including HEAD itself, can be the target.
The new commit is intended to be eventually squashed into the targeted
commit, but this is not done immediately. The squashing is done at a
later time, when you explicitly call magit-rebase-autosquash
, or use
--autosquash
with another rebase command.
Some of these commands require that you immediately write a new commit message, or that you immediately edit an existing message.
The new commits are called "squash" and "fixup" commits. The difference is that when a "squash" commit is squashed into its targeted commit, the user gets a chance to modify the message to be used for the final commit; while for "fixup" commits the existing message of the targeted commit is used as-is and the message of the "fixup" commit is discarded.
If point is on a reachable commit, then all of these commands target
that commit, without requiring confirmation. If point is on some
reachable commit, but you want to target another commit, use a prefix
argument, to select a commit in a log buffer dedicated to that task.
The meaning of the prefix argument can be inverted by customizing
magit-commit-squash-confirm
.
The command descriptions below mention the specific arguments they use
when calling git commit
. The arguments specified in the menu are
appended to those arguments.
The next two commands also exist in "instant" variants, which are
described in the next section. Those variants behave the same as the
variants described here, except that they immediately initiate an
--autosquash
rebase.
magit-commit-fixup
) ¶This command creates a new fixup commit from the staged changes, targeting the reachable commit at point, if any. Otherwise the user is prompted for a commit.
Use this variant if you want to correct some minor defect in the targeted commit, which does not require changes to the existing message of the targeted commit.
This command calls git commit --fixup=COMMIT --no-edit
.
magit-commit-squash
) ¶This command creates a new squash commit from the staged changes, targeting the reachable commit at point, if any. Otherwise the user is prompted for a commit.
Use this variant if you want a chance to make changes to the final commit message, but not until the two commits are being squashed into the final combined commit.
This command calls git commit --squash=COMMIT --no-edit
.
magit-commit-alter
) ¶This command creates a new fixup commit from the staged changes, targeting the reachable commit at point, if any. Otherwise the user is prompted for a commit.
Use this variant if you want to write the final commit message now, but (as for all variants in this section) do not want to immediately squash the fixup and targeted commits into a final combined commit.
This command calls git commit --fixup=amend:COMMIT --edit
.
magit-commit-augment
) ¶This command creates a new squash commit from the staged changes, targeting the reachable commit at point, if any. Otherwise the user is prompted for a commit.
Use this variant if you want to describe the new changes now, but want to delay writing the final message, which describes the changes in the combined commit, until you actually combine the squash and target commits into the final commit. You can think of the new message, which you write here, as a "note", to be integrated once once you write the final commit message.
This command calls git commit --squash=COMMIT --edit
.
magit-commit-revise
) ¶This command pops up a buffer containing the commit message of the reachable commit at point, if any. Otherwise the user is prompted for a commit to target.
Use this variant if you want to correct the message of the targeted
commit, but want to delay performing the --autosquash
rebase, which
actually changes that commit.
This command calls git commit --fixup=reword:COMMIT --edit
.