git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antriksh Pany <antriksh.pany@gmail.com>
To: git@vger.kernel.org
Subject: Need to change old commit (and regenerate tree)
Date: Thu, 20 May 2010 20:17:03 +0100	[thread overview]
Message-ID: <AANLkTilTAknKPFv5AZBrwsITPsRlVSnsuX8TDXlUTWmw@mail.gmail.com> (raw)

Hi all

My question is this: I have two branches (say B and C) where one is
reachable from the other (say B is ancestor of C), and if they are
separately rebased about/onto the same point, why do B and C become
non-overlapping branches?

Let me explain with an example.

Say I have the following commit line:

A--------o--------o--------o--------B--------o--------o--------C

A, B and C are branches (so that B is reachable from C, and A is
reachable from B). [For ease, I am drawing the branches at the same
level since there are no real diverging branches here.]

I then realise that I want to change the commit A and have both B and
C rebased on this changed commit.

Now when I do a
  $ git rebase --onto A2 A C

This results in two parallel trees like these:

A--------o--------o--------o--------B--------o--------o--------o(old C)

A2--------o--------o--------o--------o--------o--------o--------C

Now I go about rebasing B. I can of course 'reset' B to C~3. But
alternatively, if I decide to do a rebase:
  $ git rebase --onto A2 A B

I will end up getting

A--------o--------o--------o--------o(old B)--------o--------o--------o(old C)

A2--------o--------o--------o--------o--------o--------o--------C
   \
     ` -----o--------o--------o--------B

Instead of (what I initially expected):

A--------o--------o--------o--------o(old B)--------o--------o--------o(old C)

A2--------o--------o--------o--------B--------o--------o--------C


So what I am missing here? Aren't the new commits B~1, B~2, B~3
identical to C~4, C~5, C~6 (respectively) in all ways so as to have
gotten them the same SHA1 and hence appear as what I expected them to
appear?

I have taken a simple example here. In reality, I wanted to change a
not so new commit (on the main line), and there were many branches
diverging out from the main line after the (bad) commit. I initially
thought I could just write a simple script that would rebase all
branches that have the bad commit as an ancestor, and the new tree
would be a mirror image of the original. But that was not to be! There
is also the problem of resetting tags (and possible notes).


I am sorry if this has already been discussed, please point me to the
right resource if so.

My git version:
  $ git --version
  git version 1.7.0.5

Thanks
Antriksh Pany

             reply	other threads:[~2010-05-20 19:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-20 19:17 Antriksh Pany [this message]
2010-05-20 22:09 ` Need to change old commit (and regenerate tree) Andreas Schwab
2010-05-20 23:05   ` Jon Seymour
2010-05-21 18:18     ` Antriksh Pany
2010-05-21  5:31   ` Geert Uytterhoeven
2010-05-21 21:46     ` Antriksh Pany

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=AANLkTilTAknKPFv5AZBrwsITPsRlVSnsuX8TDXlUTWmw@mail.gmail.com \
    --to=antriksh.pany@gmail.com \
    --cc=git@vger.kernel.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).