# How to prefix existing svn remotes?

6 messages from 2009-01-22 to 2009-01-23. Participants: Sébastien Mazy, Michael J Gruber, Jakub Narebski.
Thread: https://gitlist.dev/t/17306

## Sébastien Mazy, 2009-01-22 17:32

Subject: How to prefix existing svn remotes?
Message-ID: <20090122173211.GB21798@locahost>
URL: https://gitlist.dev/e/20090122173211.GB21798%40locahost

```
Hi all,


I created a few months ago a git-svn repository using:
git svn clone -s https://my_svn_repo .

wich also created the following remotes:
git branch -r
  branch0
  tags/tag0
  trunk

I would like to prefix theses remotes, so that it shows:
git branch -r
  prefix/branch0
  prefix/tags/tag0
  prefix/trunk

Of course I should have used the -prefix back when creating the repo but
it's too late. 'git help svn' doesn't explain how to achieve that and
simply editing .git/config to add the missing prefix will cause the next
'git svn fetch' to download again the whole history (which in my case is
huge).


Is it possible? Did I miss something obvious?


Cheers,

-- 
Sébastien Mazy

```

## Michael J Gruber, 2009-01-23 11:13

Subject: Re: How to prefix existing svn remotes?
Message-ID: <4979A64E.6030608@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4979A64E.6030608%40drmicha.warpmail.net
In-Reply-To: <20090122173211.GB21798@locahost>

```
Sébastien Mazy venit, vidit, dixit 22.01.2009 18:32:
> Hi all,
> 
> 
> I created a few months ago a git-svn repository using:
> git svn clone -s https://my_svn_repo .
> 
> wich also created the following remotes:
> git branch -r
>   branch0
>   tags/tag0
>   trunk
> 
> I would like to prefix theses remotes, so that it shows:
> git branch -r
>   prefix/branch0
>   prefix/tags/tag0
>   prefix/trunk
> 
> Of course I should have used the -prefix back when creating the repo but
> it's too late. 'git help svn' doesn't explain how to achieve that and
> simply editing .git/config to add the missing prefix will cause the next
> 'git svn fetch' to download again the whole history (which in my case is
> huge).
> 
> 
> Is it possible? Did I miss something obvious?

Yes! Depends!

The following works for me:

0) fetch to make sure you're current (optional)
1) edit .git/config and add the prefix (right hand side of the
refpsecs), or really rename in any way you want
2) rename the existing remote branches in the same way

The next git svn fetch will rebuild the map file (which is fast) but not
refetch any svn revisions you already have.

Regarding the renaming: Either I'm dumb or current git branch can't
rename git svn branches. I guess it's because they are remotes but not
really. I had to resort to git update-ref. I'll look into that.

Michael

```

## Sébastien Mazy, 2009-01-23 12:42

Subject: Re: How to prefix existing svn remotes?
Message-ID: <20090123124231.GA17616@locahost>
URL: https://gitlist.dev/e/20090123124231.GA17616%40locahost
In-Reply-To: <4979A64E.6030608@drmicha.warpmail.net>

```
Hi Michael,

Thanks for your reply.

On Fri, Jan 23, 2009 at 12:13:18PM +0100, Michael J Gruber wrote:
> The following works for me:
> 
> 0) fetch to make sure you're current (optional)
> 1) edit .git/config and add the prefix (right hand side of the
> refpsecs), or really rename in any way you want

OK.

> 2) rename the existing remote branches in the same way

I'm not sure how I can do it. 'trunk' is the only remote-tracking svn
branches under .git/refs/. Here is how it looks:

ls -R .git/refs
 .git/refs:  heads  remotes  tags
 .git/refs/heads:  master
 .git/refs/remotes:  trunk

Still, a 'branch0' remote exist:

git show-ref
 refs/heads/master
 refs/remotes/branch0
 refs/remotes/trunk

-- 
Sébastien Mazy

```

## Michael J Gruber, 2009-01-23 13:02

Subject: Re: How to prefix existing svn remotes?
Message-ID: <4979BFE7.8090402@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4979BFE7.8090402%40drmicha.warpmail.net
In-Reply-To: <20090123124231.GA17616@locahost>

```
Sébastien Mazy venit, vidit, dixit 23.01.2009 13:42:
> Hi Michael,
> 
> Thanks for your reply.
> 
> On Fri, Jan 23, 2009 at 12:13:18PM +0100, Michael J Gruber wrote:
>> The following works for me:
>>
>> 0) fetch to make sure you're current (optional)
>> 1) edit .git/config and add the prefix (right hand side of the
>> refpsecs), or really rename in any way you want
> 
> OK.
> 
>> 2) rename the existing remote branches in the same way
> 
> I'm not sure how I can do it. 'trunk' is the only remote-tracking svn
> branches under .git/refs/. Here is how it looks:
> 
> ls -R .git/refs
>  .git/refs:  heads  remotes  tags
>  .git/refs/heads:  master
>  .git/refs/remotes:  trunk
> 
> Still, a 'branch0' remote exist:
> 
> git show-ref
>  refs/heads/master
>  refs/remotes/branch0
>  refs/remotes/trunk

You can do (bash)

for b in trunk branch0
do
  git update-ref refs/remotes/yournewprefix/$b refs/remotes/$b
  git update-ref -d refs/remotes/$b
done

OTOH, any incarnation of "git -m" (with or without "-r", specifying
refs/remotes/trunk, remotes/trunk or trunk) failed.

Michael

```

## Sébastien Mazy, 2009-01-23 17:13

Subject: Re: How to prefix existing svn remotes?
Message-ID: <20090123171355.GA20413@locahost>
URL: https://gitlist.dev/e/20090123171355.GA20413%40locahost
In-Reply-To: <4979BFE7.8090402@drmicha.warpmail.net>

```
On Fri, Jan 23, 2009 at 02:02:31PM +0100, Michael J Gruber wrote:
> You can do (bash)
> 
> for b in trunk branch0
> do
>   git update-ref refs/remotes/yournewprefix/$b refs/remotes/$b
>   git update-ref -d refs/remotes/$b
> done

That did the trick. Thank you so much!

By the way, my renamed remote tracking svn branches now show under
.git/refs/ as expected.

-- 
Sébastien Mazy

```

## Jakub Narebski, 2009-01-23 17:51

Subject: Re: How to prefix existing svn remotes?
Message-ID: <gld029$sa$1@ger.gmane.org>
URL: https://gitlist.dev/e/gld029%24sa%241%40ger.gmane.org
In-Reply-To: <20090123171355.GA20413@locahost>

```
Sébastien Mazy wrote:

> By the way, my renamed remote tracking svn branches now show under
> .git/refs/ as expected.

They were inside file .git/packed-refs
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```
