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

Re: Need to change old commit (and regenerate tree)

From
APAntriksh Pany <antriksh.pany@gmail.com>
Date
May 21, 2010, 21:46 UTC
Message-ID
<AANLkTin8p1Wdbx0-UXuwOtHn8Z4XKnDBAPVOumnz5YLt@mail.gmail.com>
In-Reply-To
<AANLkTinzl_sc9G1PUtLczEjHFdpRqMFuKkEiQTUXaEgQ@mail.gmail.com>
Thanks a lot.

I guess it is then not so straightforward to regenerate trees with their relative structure intact when an old commit changes. I was initially of the opinion that it would be a trivial rebasing of all branches from which the commit was reachable. Apparently, not so.

On Fri, May 21, 2010 at 6:31 AM, Geert Uytterhoeven <geert@linux-m68k.org> wrote:

Show 50 quoted lines
> On Fri, May 21, 2010 at 00:09, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> Antriksh Pany <antriksh.pany@gmail.com> writes:
>>
>>> 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?
>>
>> No, they have a different commit time, which is also part of the hash.
>
> Indeed.
>
> To avoid this, you have to:
>  - rebase B on top of A2 first,
>
>        git rebase --onto A2 A B
>
>  - rebase of C on top of the new B.
>
>        git rebase --onto B B_old C
>       ("git rebase --onto B A C" should work too, as usually git is
> smart enough to see
>        that A-B_old is already applied. Use "git rebase --skip" if it isn't)
>
> If A is an ancestor of A2, you can simplify to:
>
>    git rebase A2 B
>    git rebase B C
>
> (Disclaimer: the examples without --onto I use almost daily, the ones
> with I don't)
>
> Gr{oetje,eeting}s,
>
>                                                Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                            -- Linus Torvalds
>
Previous: Geert Uytterhoeven
Message 6 of 6 in “Need to change old commit (and regenerate tree)”
  1. Antriksh PanyMay 20, 2010
  2. Andreas SchwabMay 20, 2010
  3. Jon SeymourMay 20, 2010
  4. Antriksh PanyMay 21, 2010
  5. Geert UytterhoevenMay 21, 2010
  6. Antriksh PanyMay 21, 2010

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.