git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Aditya Garg <gargaditya08@live.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Question: is there a short way to merge the last commit to the second last one?
Date: Sun, 08 Jun 2025 13:55:46 -0700	[thread overview]
Message-ID: <xmqq5xh6vtpp.fsf@gitster.g> (raw)
In-Reply-To: <PN3PR01MB959708ED22FE7FE70C17C852B868A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM> (Aditya Garg's message of "Mon, 09 Jun 2025 00:00:30 +0530")

Aditya Garg <gargaditya08@live.com> 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.



      parent reply	other threads:[~2025-06-08 20:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-08 18:30 Question: is there a short way to merge the last commit to the second last one? Aditya Garg
2025-06-08 18:57 ` brian m. carlson
2025-06-08 19:09   ` Aditya Garg
2025-06-08 19:31   ` Phillip Wood
2025-06-08 19:35     ` Aditya Garg
2025-06-08 21:43       ` brian m. carlson
2025-06-09  4:29         ` Aditya Garg
2025-06-09 10:06     ` Phillip Wood
2025-06-09 10:35       ` Aditya Garg
2025-06-08 20:55 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq5xh6vtpp.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=gargaditya08@live.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).