# hot to fix git svn import or just discard 'branches' folder

5 messages from 2009-02-04 to 2009-02-04. Participants: Marius Seritan, Brian Gernhardt.
Thread: https://gitlist.dev/t/17562

## Marius Seritan, 2009-02-04 17:03

Subject: hot to fix git svn import or just discard 'branches' folder
Message-ID: <7E976223-6794-4E87-94A5-DEA224759700@decodeideas.com>
URL: https://gitlist.dev/e/7E976223-6794-4E87-94A5-DEA224759700%40decodeideas.com

```
I imported over night an svn repository with the command:

git svn clone --prefix svn/ -r 860  http://svn.some.com/svn/someproject

The svn repository uses the usual trunk, branches, tag so I (wrongly?)  
assumed I do not need to pass any command switches regarding the  
structure of the repo.

I obviously did something wrong because now I have a git repository  
with just one remote branch and it contains the folders trunk,  
branches and tag. I do not want to reimport because it is taking lots  
of time and bandwidth.

How can I fix this? I do not really need the old branches and tags, I  
want to be able to track new branches and I just want to have the  
trunk history.


Thanks for any pointers.

Marius

```

## Brian Gernhardt, 2009-02-04 18:39

Subject: Re: hot to fix git svn import or just discard 'branches' folder
Message-ID: <D92EB2AE-392D-4F05-8DF3-999BE78C80FF@silverinsanity.com>
URL: https://gitlist.dev/e/D92EB2AE-392D-4F05-8DF3-999BE78C80FF%40silverinsanity.com
In-Reply-To: <7E976223-6794-4E87-94A5-DEA224759700@decodeideas.com>

```

On Feb 4, 2009, at 12:03 PM, Marius Seritan wrote:

> I imported over night an svn repository with the command:
>
> git svn clone --prefix svn/ -r 860  http://svn.some.com/svn/ 
> someproject
>
> The svn repository uses the usual trunk, branches, tag so I  
> (wrongly?) assumed I do not need to pass any command switches  
> regarding the structure of the repo.

"git svn clone URL" attempts to act like "svn co URL", but with  
history.  If you only want to download the trunk, then you should add  
"/trunk" to the end of the URL.  If you want to capture all the  
branches, tags, etc you should use "--stdlayout" (also spelled "-s").

> I obviously did something wrong because now I have a git repository  
> with just one remote branch and it contains the folders trunk,  
> branches and tag. I do not want to reimport because it is taking  
> lots of time and bandwidth.

I believe fixing this without reimporting requires using "git filter- 
branch".  I'm unfamiliar with it, so I can't help you with that part.

However, I'm curious as to why this took a lot of time because the "-r  
860" on the command line should tell git-svn to only download a single  
revision.  Is it a particularly repository?

~~ Brian

```

## Marius Seritan, 2009-02-04 19:05

Subject: Re: hot to fix git svn import or just discard 'branches' folder
Message-ID: <5713EFD1-E6E7-4FD5-BF17-FDA5FF6F7C6B@decodeideas.com>
URL: https://gitlist.dev/e/5713EFD1-E6E7-4FD5-BF17-FDA5FF6F7C6B%40decodeideas.com
In-Reply-To: <D92EB2AE-392D-4F05-8DF3-999BE78C80FF@silverinsanity.com>

```
Thanks Brian,


On Feb 4, 2009, at 10:39 AM, Brian Gernhardt wrote:

>
> On Feb 4, 2009, at 12:03 PM, Marius Seritan wrote:
>
>> I imported over night an svn repository with the command:
>>
>> git svn clone --prefix svn/ -r 860  http://svn.some.com/svn/someproject
>>
>> The svn repository uses the usual trunk, branches, tag so I  
>> (wrongly?) assumed I do not need to pass any command switches  
>> regarding the structure of the repo.
>
> "git svn clone URL" attempts to act like "svn co URL", but with  
> history.  If you only want to download the trunk, then you should  
> add "/trunk" to the end of the URL.  If you want to capture all the  
> branches, tags, etc you should use "--stdlayout" (also spelled "-s").

I want to capture the current trunk and any new branches. It seems the  
-s is required if I do a reimport.


>
>
>> I obviously did something wrong because now I have a git repository  
>> with just one remote branch and it contains the folders trunk,  
>> branches and tag. I do not want to reimport because it is taking  
>> lots of time and bandwidth.
>
> I believe fixing this without reimporting requires using "git filter- 
> branch".  I'm unfamiliar with it, so I can't help you with that part.

Thanks, I will look into it. From the first read this seems to be  
pretty advanced.

>
>
> However, I'm curious as to why this took a lot of time because the "- 
> r 860" on the command line should tell git-svn to only download a  
> single revision.  Is it a particularly repository?

All of the repository was imported including branches in spite of the - 
r. This is private repository for a company's web site, it has your  
usual assortment of jars and the history has a dozen branches and a  
couple of tags.  The size on the disk is about 3GB, I was a bit  
surprised by it.

Marius

>
>
> ~~ Brian

```

## Marius Seritan, 2009-02-04 19:24

Subject: Re: hot to fix git svn import or just discard 'branches' folder
Message-ID: <06C1D783-D51B-49E9-92A2-C1EA035BE3D6@decodeideas.com>
URL: https://gitlist.dev/e/06C1D783-D51B-49E9-92A2-C1EA035BE3D6%40decodeideas.com
In-Reply-To: <5713EFD1-E6E7-4FD5-BF17-FDA5FF6F7C6B@decodeideas.com>

```

On Feb 4, 2009, at 11:05 AM, Marius Seritan wrote:
>>
>> I believe fixing this without reimporting requires using "git  
>> filter-branch".  I'm unfamiliar with it, so I can't help you with  
>> that part.
>
> Thanks, I will look into it. From the first read this seems to be  
> pretty advanced.

Ok, I think I killed it :-/

I did
git filter-branch --subdirectory-filter trunk -- --all

This cleaned up git and I have just the trunk for 218MB, that's much  
more acceptable. Unfortunately 'git svn rebase' now returns:

Unable to determine upstream SVN information from working tree history

I went into the .git/config and added a trunk but no luck. I also  
edited .git/svn/.metadata in the same way.

As another data point git svn log is still working.


Marius

```

## Marius Seritan, 2009-02-04 20:21

Subject: Re: hot to fix git svn import or just discard 'branches' folder
Message-ID: <217FD3AA-39FA-4F81-A4A6-DC7F6F6905B5@decodeideas.com>
URL: https://gitlist.dev/e/217FD3AA-39FA-4F81-A4A6-DC7F6F6905B5%40decodeideas.com
In-Reply-To: <06C1D783-D51B-49E9-92A2-C1EA035BE3D6@decodeideas.com>

```

On Feb 4, 2009, at 11:24 AM, Marius Seritan wrote:

>
> On Feb 4, 2009, at 11:05 AM, Marius Seritan wrote:
>>>
>>> I believe fixing this without reimporting requires using "git  
>>> filter-branch".  I'm unfamiliar with it, so I can't help you with  
>>> that part.
>>
>> Thanks, I will look into it. From the first read this seems to be  
>> pretty advanced.
>
> Ok, I think I killed it :-/
>
> I did
> git filter-branch --subdirectory-filter trunk -- --all
>
> This cleaned up git and I have just the trunk for 218MB, that's much  
> more acceptable. Unfortunately 'git svn rebase' now returns:
>
> Unable to determine upstream SVN information from working tree history
>
> I went into the .git/config and added a trunk but no luck. I also  
> edited .git/svn/.metadata in the same way.
>
> As another data point git svn log is still working.
>
>
> Marius
>
>


Last follow-up on svn git. I ended up re-reading the docs (duh) and  
doing the following:

git svn init -s --prefix=svn/   http://svn.name.com/svn/project
git svn fetch -r 800:HEAD

This brought down the last 2 branches and the trunk. It took a couple  
of minutes and uses 120MB of disk space. Much better than hours and  
3GB of disk.

Love it,

Marius

```
