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

Re: collapsing commits with rebase

From
Sitaram Chamarty <sitaramc@gmail.com>
Date
Jan 8, 2009, 04:09 UTC
Message-ID
<slrngmav3b.20e.sitaramc@sitaramc.homelinux.net>
In-Reply-To
<200901072011.37299.bss@iguanasuicide.net>
On 2009-01-08, Boyd Stephen Smith Jr. <bss@iguanasuicide.net> wrote:
>>    A---B---C---D---E---F
> Assuming you also have a ref (e.g. Foo) that points to F:
> git checkout sha(B)
> git merge -s sha(D)

I think you now need to do a commit (assuming you meant "--squash"). Squash will not commit, and your rebase below (if it runs at all -- I suspect it will refuse to run) will hard reset to B, the current HEAD. IOW

> After the merge:
> A -> B -> C -> D -> E -> F [Foo]
>      |
>      +--> [HEAD]
is not true.  You have C+D in the index, not in the tree.
> git rebase --onto $(cat .git/HEAD) sha(E) Foo

Also I think you have an off-by-one error here; you need sha(D) in that rebase command, not sha(E).

As your rebase command stands, you will lose commit E completely; neither the merge nor the rebase will pick it up.

[Haven't tested, but I *think* I understand rebase well enough now to say so...]

Previous: Geoff RussellNext: Boyd Stephen Smith Jr.
Message 10 of 12 in “collapsing commits with rebase”
  1. Geoff RussellJan 8, 2009
  2. Johannes SchindelinJan 8, 2009
  3. Geoff RussellJan 8, 2009
  4. Johannes SchindelinJan 8, 2009
  5. Geoff RussellJan 10, 2009
  6. Boyd Stephen Smith Jr.Jan 8, 2009
  7. Miklos VajnaJan 8, 2009
  8. Boyd Stephen Smith Jr.Jan 8, 2009
  9. Geoff RussellJan 8, 2009
  10. Sitaram ChamartyJan 8, 2009
  11. Boyd Stephen Smith Jr.Jan 8, 2009
  12. nadim khemirJan 10, 2009

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.