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

Re: squash commits deep down in history

From
HMHenning Moll <newsscott@gmx.de>
Date
Oct 23, 2014, 22:20 UTC
Message-ID
<54497F1A.8050606@gmx.de>
In-Reply-To
<54496036.8080109@kdbg.org>
Am 23.10.2014 um 22:08 schrieb Johannes Sixt:
> Use git-replace do construct a squashed commit that replaces the last 
> child in each run such that its parent points to the parent of the 
> first in the run. Then use a git-filterbranch without filters to burn 
> the parenthood into the history. -- Hannes 
Wow, cool. Thanks a lot for the hint.
I managed to do the following: Suppose i have the following history
A - B - C - D   <-master

and i want to squash B and C together. First i create a temporary branch on A and switch to it. Then i cherry-pick B and C without commit. So all the changes are merged into the index. Then i commit a single commit "M". The history now looks like

   M             <-temp
  /
A - B - C - D   <-master
Using
$ git replace C M
leads to
    temp
         |
         v
A -     M - D   <-master

As far as i understand, such a repalce is something like a "symbolic link". Is that right?

This is interesting: Before filter-branch, the deletion of the replace would lead to the initial situation (ABCD). After filter-branch, the history is (AM'D'). The replace still exists but is now something like a "dead link". I may come to life again after "git resetting" to somewhere before filter-branch. Even "before" creating the replace (the replace ref itself is not part of the history). Even if you gor before creation of M: The link still works as long as M is not garbage collected. I was very irritated after resetting to where i commited D, and still seeing A-M-D.

Somehow logical, somehow crazy! I am still a git learner ;-)
Two questions remain for me:
1. Is there a more elegant way to build M?
2. Having a replace "in place" before filter-branch: Is there a way to 
find out what the replace is hiding? A simple "git log C" produces 
"M-A". How to get "C-B-A"?

Best regards Henning

Previous: Johannes SixtNext: Jakub Narębski
Message 3 of 5 in “squash commits deep down in history”
  1. Henning MollOct 23, 2014
  2. Johannes SixtOct 23, 2014
  3. Henning MollOct 23, 2014
  4. Jakub NarębskiOct 24, 2014
  5. Phil HordNov 4, 2014

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.