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

Re: Splitting a commit with rebase -i and keeping a commit message

From
TCTim Chase <git@tim.thechases.com>
Date
Apr 17, 2013, 03:04 UTC
Message-ID
<20130416220407.105b354e@bigbox.christie.dr>
In-Reply-To
<CAJDDKr64KpF-DP5Axj+vhxRQ1rrig=pm25T3Angp8GaKK_CHMA@mail.gmail.com>
On 2013-04-16 19:29, David Aguilar wrote:
Show 21 quoted lines
> On Tue, Apr 16, 2013 at 6:38 PM, Tim Chase <git@tim.thechases.com>
> wrote:
> >   git commit -am "Long-bodied commit comment about b.txt changes"
> >   # whoops, just wanted B
> 
> Save the commit's ID here so that we can reuse its message later:
> 
>     orig_commit=$(git rev-parse HEAD)
> 
> >   git rebase -i HEAD^^
> >   # change the "Added b.txt..." commit to "edit"
> >   git reset HEAD^  # pull the changes out of the pending commit
> >   git add a.txt
> >   git commit -m "Tweaked a.txt"
> >   git add b.txt
> >   git commit ${MAGIC_HERE}
> 
> ...reuse the commit message by passing the "-c" option to "git
> commit":
> 
>     git commit --reset-author -c $orig_commit

Wild guess or not, using -c worked great. With the appropriate section of the docs now in hand, I discovered that it could even be simplified to just

  git commit -c ORIG_HEAD [...]
as rebase stashes that information away for me already as "ORIG_HEAD".
Thanks!
-tkc
Previous: David AguilarNext: Johannes Sixt
Message 3 of 4 in “Splitting a commit with rebase -i and keeping a commit message”
  1. Tim ChaseApr 17, 2013
  2. David AguilarApr 17, 2013
  3. Tim ChaseApr 17, 2013
  4. Johannes SixtApr 17, 2013

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.