threads / discuss / 3403

Prepend the history of one git tree to another

Subject: Prepend the history of one git tree to another

## tl;dr

6 messages between Feb 20, 2006 and Feb 20, 2006.

replies: 5people: 4as markdown or json

Thomas Glanzmann· Feb 20, 2006, 09:09 UTC · lore

Hello, I have two trees: blastwave and blastwave.old. blastwave.old is the BitKeeper -> CVS -> GIT Tree of the project and blastwave is the newer one that I started when I stoped using bitkeeper. What I want is to append the history of blastwave to blastwave.old. The problem is that I need to create new commit objects for every commit I want to append to the old history. Is there a script which does that for me? Or do I have to write this script myself?

        Thomas
Andreas Ericsson· Feb 20, 2006, 10:14 UTC · re: Thomas Glanzmann · lore

Re: Prepend the history of one git tree to another

Thomas Glanzmann wrote:
Show 9 quoted lines
> Hello,
> I have two trees: blastwave and blastwave.old. blastwave.old is the
> BitKeeper -> CVS -> GIT Tree of the project and blastwave is the newer
> one that I started when I stoped using bitkeeper. What I want is to 
> append the history of blastwave to blastwave.old. The problem is that I
> need to create new commit objects for every commit I want to append to
> the old history. Is there a script which does that for me? Or do I have
> to write this script myself?
> 

Something like this might do the trick, depending on how linear your ancestry graph is:

$ cd blastwave $ first=$(git rev-list HEAD | tail -n 1) $ git format-patch -k --stdout $first..HEAD > ../blw.mbox $ cd ../blastwave.old $ git am -k -3 ../blw.mbox

YMMV though, so set an anchor tag at the HEAD of blastwave.old so you can return to it if things go awry. If the history is very non-linear I think you'll have to do the same for each and every branch, although you'd have to use "git merge-base" to figure out how long to go.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Thomas Glanzmann· Feb 20, 2006, 10:43 UTC · re: Andreas Ericsson · lore

Re: Prepend the history of one git tree to another

Hello Andreas,
> Something like this might do the trick, depending on how linear your 
> ancestry graph is:
Show 5 quoted lines
> $ cd blastwave
> $ first=$(git rev-list HEAD | tail -n 1)
> $ git format-patch -k --stdout $first..HEAD > ../blw.mbox
> $ cd ../blastwave.old
> $ git am -k -3 ../blw.mbox

My graph is very linear. However. I have binaries checked into my tree. I am not sure if format-patch can handle this.

        Thomas
Ryan Anderson· Feb 20, 2006, 10:57 UTC · re: Thomas Glanzmann · lore

Re: Prepend the history of one git tree to another

Thomas Glanzmann wrote:
Show 23 quoted lines
>Hello Andreas,
>
>  
>
>>Something like this might do the trick, depending on how linear your 
>>ancestry graph is:
>>    
>>
>
>  
>
>>$ cd blastwave
>>$ first=$(git rev-list HEAD | tail -n 1)
>>$ git format-patch -k --stdout $first..HEAD > ../blw.mbox
>>$ cd ../blastwave.old
>>$ git am -k -3 ../blw.mbox
>>    
>>
>
>My graph is very linear. However. I have binaries checked into my tree.
>I am not sure if format-patch can handle this.
>  
>

I wrote a program called "graft-ripple", that takes a commit, and rewrites the current branch's history to reflect as if it started at that commit.

It doesn't ever actually work with diffs or anything, it just reads commits and trees and recreates them.

It's in the list archives, but I appear to have deleted it when I was cleaning up my archives.

http://www.gelato.unsw.edu.au/archives/git/0511/12965.html
Hope this helps!
-- 
Ryan Anderson
  sometimes Pug Majere
Thomas Glanzmann· Feb 20, 2006, 12:20 UTC · re: Ryan Anderson · lore

Re: Prepend the history of one git tree to another

Hello,
> I wrote a program called "graft-ripple", that takes a commit, and
> rewrites the current branch's history to reflect as if it started at
> that commit. It doesn't ever actually work with diffs or anything, it
> just reads commits and trees and recreates them.
> http://www.gelato.unsw.edu.au/archives/git/0511/12965.html
that is *exactly* what I was looking for. Thanks.
> Hope this helps!
Well it does!
Thanks,
        Thomas
Johannes Schindelin· Feb 20, 2006, 12:51 UTC · re: Thomas Glanzmann · lore

Re: Prepend the history of one git tree to another

Hi,
On Mon, 20 Feb 2006, Thomas Glanzmann wrote:
Show 13 quoted lines
> Hello Andreas,
> 
> > Something like this might do the trick, depending on how linear your 
> > ancestry graph is:
> 
> > $ cd blastwave
> > $ first=$(git rev-list HEAD | tail -n 1)
> > $ git format-patch -k --stdout $first..HEAD > ../blw.mbox
> > $ cd ../blastwave.old
> > $ git am -k -3 ../blw.mbox
> 
> My graph is very linear. However. I have binaries checked into my tree.
> I am not sure if format-patch can handle this.

Do you need the history at all times? If not, you could just make a graft file. If you need it always, you could even check in a version of the graft file (but remember to copy it to .git/info/grafts, too).

Hth, Dscho

← back to recent threads