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

Feature Request: `git commit --amend-to`

From
AGAidan Gallagher <aidgal2@gmail.com>
Date
Sep 24, 2021, 16:04 UTC
Message-ID
<CAENgTz0st6RpnVusP67-SSh2eENSxQn1_qiEqUDiMKzg=r54vQ@mail.gmail.com>
In-Reply-To
<CAENgTz2DoStQEqoKYKa-qMcyaez64u55mnv1HHOzDm392fuEqQ@mail.gmail.com>

`git commit --amend` is very useful for adding changes to the previous commit quickly.

Unfortunately, it is more difficult to add changes to older commits. To do so I have to enter interactive rebase, mark the commit to change, make the changes, amend the previous commit, and continue the interactive rebase.

It would be nice if there was a single command to do this like `git commit --amend-to SHA`

I have solved this issue for myself with this handy alias I found online ``` git config --global alias.amend-to '!f() { SHA=`git rev-parse "$1"`; git commit --fixup "$SHA" && GIT_SEQUENCE_EDITOR=true git rebase --interactive --autosquash "$SHA^"; }; f' ```

I think it would be beneficial if a command `git commit --amend-to` could be officially added.

Thanks, Aidan Gallagher

Next: Carlo Arenas
Message 1 of 7 in “Feature Request: `git commit --amend-to`”
  1. Aidan GallagherSep 24, 2021
  2. Carlo ArenasSep 24, 2021
  3. Glen ChooSep 28, 2021
  4. Ævar Arnfjörð BjarmasonSep 28, 2021
  5. Glen ChooSep 29, 2021
  6. Fabian StelzerSep 30, 2021
  7. Phillip WoodSep 30, 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.