git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Henning Moll <newsScott@gmx.de>
To: git@vger.kernel.org
Cc: Johannes Sixt <j6t@kdbg.org>
Subject: Re: squash commits deep down in history
Date: Fri, 24 Oct 2014 00:20:10 +0200	[thread overview]
Message-ID: <54497F1A.8050606@gmx.de> (raw)
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

  reply	other threads:[~2014-10-23 22:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 12:34 squash commits deep down in history Henning Moll
2014-10-23 20:08 ` Johannes Sixt
2014-10-23 22:20   ` Henning Moll [this message]
2014-10-24 11:43   ` Jakub Narębski
2014-11-04 17:25 ` Phil Hord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54497F1A.8050606@gmx.de \
    --to=newsscott@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).