# Prepend the history of one git tree to another

6 messages from 2006-02-20 to 2006-02-20. Participants: Thomas Glanzmann, Andreas Ericsson, Ryan Anderson, Johannes Schindelin.
Thread: https://gitlist.dev/t/3403

## Thomas Glanzmann, 2006-02-20 09:09

Subject: Prepend the history of one git tree to another
Message-ID: <20060220090909.GT6558@cip.informatik.uni-erlangen.de>
URL: https://gitlist.dev/e/20060220090909.GT6558%40cip.informatik.uni-erlangen.de

```
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, 2006-02-20 10:14

Subject: Re: Prepend the history of one git tree to another
Message-ID: <43F99684.5070403@op5.se>
URL: https://gitlist.dev/e/43F99684.5070403%40op5.se
In-Reply-To: <20060220090909.GT6558@cip.informatik.uni-erlangen.de>

```
Thomas Glanzmann wrote:
> 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, 2006-02-20 10:43

Subject: Re: Prepend the history of one git tree to another
Message-ID: <20060220104345.GG26454@cip.informatik.uni-erlangen.de>
URL: https://gitlist.dev/e/20060220104345.GG26454%40cip.informatik.uni-erlangen.de
In-Reply-To: <43F99684.5070403@op5.se>

```
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.

        Thomas

```

## Ryan Anderson, 2006-02-20 10:57

Subject: Re: Prepend the history of one git tree to another
Message-ID: <43F9A0B3.6020304@michonline.com>
URL: https://gitlist.dev/e/43F9A0B3.6020304%40michonline.com
In-Reply-To: <20060220104345.GG26454@cip.informatik.uni-erlangen.de>

```
Thomas Glanzmann wrote:

>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, 2006-02-20 12:20

Subject: Re: Prepend the history of one git tree to another
Message-ID: <20060220122052.GD5318@cip.informatik.uni-erlangen.de>
URL: https://gitlist.dev/e/20060220122052.GD5318%40cip.informatik.uni-erlangen.de
In-Reply-To: <43F9A0B3.6020304@michonline.com>

```
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, 2006-02-20 12:51

Subject: Re: Prepend the history of one git tree to another
Message-ID: <Pine.LNX.4.63.0602201350210.23862@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0602201350210.23862%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <20060220104345.GG26454@cip.informatik.uni-erlangen.de>

```
Hi,

On Mon, 20 Feb 2006, Thomas Glanzmann wrote:

> 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

```
