# Import existing (old) topic branches in topgit

2 messages from 2010-09-14 to 2010-09-15. Participants: Guilhem Bonnefille, martin f krafft.
Thread: https://gitlist.dev/t/25104

## Guilhem Bonnefille, 2010-09-14 20:44

Subject: Import existing (old) topic branches in topgit
Message-ID: <AANLkTima2NsEWuT85oFZGpfCQrsrqy5KsQSOez3B9i-7@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTima2NsEWuT85oFZGpfCQrsrqy5KsQSOez3B9i-7%40mail.gmail.com

```
Hi all,

After trying to manually maintain many topic branches before sending
them upstream, I recently discovered that topgit seems to become my
best friend.

But as I'm new to this tool, I don't know what's the best way to
import existing branches in topgit.

What I mean is:
* I already have topic branches, with long history and regular merges
with upstream.
* I want to manage the related topic via topgit
* I whish to keep my own history (if possible)


Can experimented users give me some tips on how to do this?

Thanks in advance.
-- 
Guilhem BONNEFILLE
-=- JID: guyou@im.apinc.org MSN: guilhem_bonnefille@hotmail.com
-=- mailto:guilhem.bonnefille@gmail.com
-=- http://nathguil.free.fr/

```

## martin f krafft, 2010-09-15 04:55

Subject: Re: Import existing (old) topic branches in topgit
Message-ID: <20100915045509.GA16770@fishbowl.rw.madduck.net>
URL: https://gitlist.dev/e/20100915045509.GA16770%40fishbowl.rw.madduck.net
In-Reply-To: <AANLkTima2NsEWuT85oFZGpfCQrsrqy5KsQSOez3B9i-7@mail.gmail.com>

```
also sprach Guilhem Bonnefille <guilhem.bonnefille@gmail.com> [2010.09.14.2244 +0200]:
> But as I'm new to this tool, I don't know what's the best way to
> import existing branches in topgit.

There is tg-import, but it looks like it rewrites the history, which
you might not want.

This should be trivially possible, and it would be nice if TopGit
could help you, but for now you will have to do this manually. The
following is an example for the simple case when branch foo depends
on master, and you want to convert foo:

1. git checkout foo    # the topic branch
2. git update-ref refs/top-bases/foo $(git merge-base master HEAD)
3. echo master > .topdeps
4. git format-patch --stdout -s HEAD^ | sed -e 1d -e '/---/,$d' -e '/^Date:/d' > .topmsg
5. git add .top(deps|msg)
6. git commit -sm'convrting branch to topgit format'
7. tg summary

Now: will you write a new tg-import or tg-convert? ;)

Cheers,

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
a: no.
q: should i include quotations after my reply?
 
spamtraps: madduck.bogus@madduck.net

```
