Subject: Re: Question: is there a short way to merge the last commit to the second last one?

From: Junio C Hamano <[email-masked]>
Date: Sun, 08 Jun 2025 13:55:46 -0700

Aditya Garg <[email-masked]> writes:

> Hi all
>
> This is something I usually come across. Sometimes I make a
> mistake in a commit, and then I create a new commit with a
> correction. After that I git rebase -i and use the fixup option to
> make the fixup commit a part of the main commit.
>
> I was wondering if there is a command, like git fixup or something
> that could make this process easier? I know about git squash but I
> prefer doing fixup.

If your "After that" is "immediately after that before piling any
more commits on top of the history", then the standard answer would
be "rebase --autosquash", i.e.

 ... work work work
 $ git commit [options and arguments]
 ... oops that needs further change
 ... work more
 $ git commit -m 'fixup' [options and arguments]
 $ git rebase --autosquash HEAD~2

But if it is truly immediately after that", then

 ... work work work
 $ git commit [options and arguments]
 ... oops that needs further change
 ... work more
 $ git commit --amend [options and arguments]

would be even simpler.