From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from complex.crustytoothpaste.net (complex.crustytoothpaste.net [172.105.7.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA04D1519BA for ; Sun, 8 Jun 2025 18:57:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=172.105.7.114 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749409075; cv=none; b=DTg/nqJGzGT2lK28IE9rKdd8SUf9DBFyLwDzGfp5l1qcVbLstazNJA67YBZqzyO5gVJL0uwGQxkcDvnw21Nxu1RJ2xoBAppYzFqM5tqVYILZ7OS0IkPOuGYZSOZAjZaS8y9Nu5RzAjTyvEzrITsoCdRprzaKGxwmTuS3xjggXU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749409075; c=relaxed/simple; bh=4mPmZH7qsGEPLl/QBHoSiFKH62qFelggEWevNBHSySk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b8cTvPsp3pFu+9lRKhCrbU8YDlE5tAByvbvwIaJ7HvdgLqcah+M+nX8bWdHAzyEu2rP7RPPiVbXt7rFOJPrHeIKkWuSQYg750tTAq3DkAqJ+j3pTlf1NsJcJZslENGx6qzelNcbnSBlrRCfLOdtuxaMNS3NtDiw/2SyFg7nBHkc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=crustytoothpaste.net; spf=pass smtp.mailfrom=crustytoothpaste.net; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b=gnsMuJa2; arc=none smtp.client-ip=172.105.7.114 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=crustytoothpaste.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=crustytoothpaste.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="gnsMuJa2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1749409065; bh=4mPmZH7qsGEPLl/QBHoSiFKH62qFelggEWevNBHSySk=; h=Date:From:To:Cc:Subject:References:Content-Type: Content-Disposition:In-Reply-To:From:Reply-To:Subject:Date:To:CC: Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To:References: Content-Type:Content-Disposition; b=gnsMuJa2R6d6uYT0tpy/mI3B5q8FCTx5EC8c/rFk4oDnly7Qqtif7l+LUl0k2CE2h EbWXeJdpHlNQsAUOCMNPtZiAEZQ3OlpX9Ga3zg6stukYCX1uw+gSS6ojNFixSOQRLe HaWusm3Ce3GQQ0rmK7FpUM2cQBOjuY4oA5AH3vYQFSVIiR17Xxu+437OzEe39QOXhK Z8z6Zz9m4e/PeSJhfXnEGhMXcC1pjfAUDpfNrgim5LoxyKaQTApDjEdlaRtLu66auP UjTuLent/SqscpYRrQQYpkCRlLjbMGYqDi61J+fJe9zxhWoIZDKlS7v6+Kebn32QyO OrxgvBY5rnatNjdqPVnIFhy7ahbLZaCcsWg3QwWJBi8jz1O3pVaUf3PZEUorRl/5V0 BjA5nqrFg20qLl3+DWqaEVPuY8kzvTaNCsho8cVspq392SC5tWeKzgFymdb/XBPETo GyDiy1jQatJIV2r0GyYnytXpBRmix+2hRDimXqaAg/mA8ISsApc Received: from tapette.crustytoothpaste.net (bras-base-toroon0964w-grc-75-76-65-21-254.dsl.bell.ca [76.65.21.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by complex.crustytoothpaste.net (Postfix) with ESMTPSA id E0B0620038; Sun, 8 Jun 2025 18:57:45 +0000 (UTC) Date: Sun, 8 Jun 2025 18:57:44 +0000 From: "brian m. carlson" To: Aditya Garg Cc: "git@vger.kernel.org" Subject: Re: Question: is there a short way to merge the last commit to the second last one? Message-ID: Mail-Followup-To: "brian m. carlson" , Aditya Garg , "git@vger.kernel.org" References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fF8ZQG9Op3FACYsH" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.13 (2024-03-09) --fF8ZQG9Op3FACYsH Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2025-06-08 at 18:30:30, Aditya Garg wrote: > Hi all Hi, > 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. >=20 > 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. You are hardly the only person to have this problem. It happens to me and lots of other people very frequently and so we do have a couple ways to fix that. If the mistake you want to fix is in the most recent commit, instead of making a new commit, you can do `git commit --amend`. That updates the last commit with the changes you've staged via `git add` and `git rm`. It also allows you to edit the message; if you don't want that, you can pass the `--no-edit` option. The other situation is that the mistake is in an older commit. Here, we have a special variant of `git commit` that will mark the commit to be automatically fixed up. You could say something like `git commit --fixup HEAD^` (or whatever revision you like instead of `HEAD^`). Then, when you do `git rebase -i --autosquash`, it will automatically be moved to the proper location and marked for fixup. If you want to change the commit message as well, you can replace `--fixup` with `--squash` and you'll get prompted for something you can put in the commit message. When you squash it, then you'll be prompted to merge the two commit messages (the old and new). If your goal is to just do the fixups and squash and not anything else interactive, then you can do this: GIT_SEQUENCE_EDITOR=3Dtrue git rebase -i --autosquash in a POSIX shell (that is, on macOS or Linux or under Git Bash, but not under Powershell or CMD). The `GIT_SEQUENCE_EDITOR=3Dtrue` tells Git not to edit the sequence list (also known as the todo list, which contains the pick, fixup, and squash commands) and just perform the rebase. You can see an alias for doing this at [0], which may be helpful as well. [0] https://github.com/bk2204/dotfiles/blob/5e74a513ae133ec30b20992fb4c2f96= 7fa6f047b/git/gitconfig#L41 --=20 brian m. carlson (they/them) Toronto, Ontario, CA --fF8ZQG9Op3FACYsH Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- wr0EABYKAG8FgmhF3ScJEHwMSWKIh6KBRxQAAAAAAB4AIHNhbHRAbm90YXRpb25z LnNlcXVvaWEtcGdwLm9yZ3BXqE/xhM/9Pjuqjj6dhfFVw99G7s9QirLLGDuFF/xN FiEECCzmip28ZfuD0cORfAxJYoiHooEAAK4wAP9zTMKuPb3hegGAnSmo6yVN6dLL sZ9aCT1FFnM3H8JscAEAxutS+GSBurTuz/kDOssCt6BGWscmYmVocRq6WMEH3gU= =U9HP -----END PGP SIGNATURE----- --fF8ZQG9Op3FACYsH--