git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to interactively rebase-and-reword nth commit?

From
KKKonstantin Kharlamov <hi-angel@yandex.ru>
Date
Aug 27, 2021, 09:18 UTC
Message-ID
<826fa09ce470d1a3f06714cdd7f75891fecda676.camel@yandex.ru>
In-Reply-To
<YShISkyN7stYtkV2@coredump.intra.peff.net>
On Thu, 2021-08-26 at 22:04 -0400, Jeff King wrote:
Show 19 quoted lines
> On Wed, Aug 25, 2021 at 05:06:03PM +0300, Konstantin Kharlamov wrote:
> 
> > Any ideas, how can I tell `git` that I want to "reword" nth commit right
> > away? Sure,
> > I am not the first one to stumble upon it, am I? Any ideas?
> 
> Have you looked at the new --fixup options in 2.32? E.g.:
> 
>   git commit --fixup reword:HEAD~2
> 
> will immediately drop you in an editor to adjust the commit message. The
> result is a new "fixup" commit which is then applied when you
> autosquash. So you could do multiple such adjustments, and then:
> 
>   GIT_EDITOR=: git rebase -i --autosquash
> 
> to apply them all to the appropriate spots.
> 
> -Peff
Thank you for the suggestion! I think I gonna stick to the `rebase-at` now that I know the way to solve my problem with GIT_SEQUENCE_EDITOR. The "rebase-at" workflow sounds better optimized to me, due to lack of the `git rebase -i --autosquash` step.
I get that the idea with autosquash that you can remove the commit if you realize you did something wrong. But I usually have a copy of the local branch on a remote repo, so in rare cases I realize I want to undo the change I can simply run `git reset --hard origin/mybranch` ☺ (otherwise, reflog is also a thing).
Previous: Jeff King
Message 7 of 7 in “How to interactively rebase-and-reword nth commit?”
  1. Konstantin KharlamovAug 25, 2021
  2. Ævar Arnfjörð BjarmasonAug 25, 2021
  3. Martin ÅgrenAug 25, 2021
  4. Konstantin KharlamovAug 25, 2021
  5. ZheNing HuAug 26, 2021
  6. Jeff KingAug 27, 2021
  7. Konstantin KharlamovAug 27, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.