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

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

From
Glen Choo <chooglen@google.com>
Date
Sep 28, 2021, 16:52 UTC
Message-ID
<kl6l1r58r6ba.fsf@chooglen-macbookpro.roam.corp.google.com>
In-Reply-To
<CAPUEspgr71t-thozi+Ez4xwxAkSJizsLuV=0TnROKZ85M6-kBg@mail.gmail.com>
Carlo Arenas <carenas@gmail.com> writes:
Show 6 quoted lines
>   git commit --fixup reword:$SHA && EDITOR=true git rebase
> --interactive --autosquash "$SHA^"
>
> granted it is not 1 command, but usually I find it useful to do
> several of those and then one single
> rebase at the end.

This is fairly similar to what I use, though I use this through the Magit Emacs plugin.

My concern with "--amend-to" is that the semantics aren't as simple as --amend.

With --amend, you know you're working on the branch tip, so it's relatively simple to discard the last commit and create a new one.

With something like --amend-to, you aren't just modifying a single commit, you are also introducing a potential merge conflict with every commit after that. You would have to provide some kind of facility for users to fix the merge conflicts. A command like git rebase --autosquash does a good job at communicating to users that they are actually doing a rebase and they need to be prepared to fix problems through a rebase UX. However, git commit --amend-to communicates none of that. A user who takes a cursory glance at git commit --amend-to has no idea that they are potentially comitting to a rebase.

I personally think the current UI makes sense given how Git works. I also wish that it were easier to do --amend-to, but I think the problem has more to do with how Git manages merges and conflicts and less to do with having shortcuts in the CLI.

Previous: Carlo ArenasNext: Ævar Arnfjörð Bjarmason
Message 3 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.