简体   繁体   中英

Missing branches cloning a non-standard svn repository using git-svn clone

I am a complete git newbie and I want to clone my svn repository using git-svn. However, the branches are missing after the clone command is run.

The repo layout is as follows:

trunk/
branches/team/releases/release-1
branches/team/releases/release-2
...
branches/development/user1/feature1
branches/development/user1/feature2
branches/development/user2/feature3
branches/development/user2/feature4
...
tags/release1
tags/release2

The command I'm using is:

git svn clone --trunk=/trunk --branches=branches/*/* --tags=tags/*/* --prefix=svn/ --authors-file=authors.txt <my-repo> <git-repo-name>

I've tried modifying the branches option to /branches/development/user1/* and /branches/development/user1/*/* (and also using both together) and running the clone command again to see if any additional branches are picked up but they're not.

Is it OK to run clone again or to I have to start from scratch and delete the git repo?

All I can see if I run git branch -r after cloning is:

svn/development/user1
svn/development/user1
svn/team/releases
svn/trunk
note that all the tags are present but omitted for brevity

How do I get the missing branches?

This is not a duplicate of Cloning a Non-Standard Svn Repository with Git-Svn or how to use nested branches through git-svn .

It is in fact possible to do this without re-cloning the entire repository which can take many hours for a large subversion repository. I did this by editing the config file in the .git directory to get my branches and tags setup appropriately.

If you do a plain git svn fetch , nothing will happen. The trick is to trick/force Git to refetch all the revisions:

git svn fetch 0:HEAD

This command causes all the tags/branches to be brought in without going through the long and tedious import of the trunk, it was smart enough to skip the trunk revisions already imported in the initial run. I now have my SVN tags/branches in my existing Git repository without a fresh clone.

You can specify the --branches tag more than once. From the docs :

These are optional command-line options for init. Each of these flags can point to a relative repository path (--tags=project/tags) or a full url (--tags= https://foo.org/project/tags ). You can specify more than one --tags and/or --branches options, in case your Subversion repository places tags or branches under multiple paths. The option --stdlayout is a shorthand way of setting trunk,tags,branches as the relative paths, which is the Subversion default. If any of the other options are given as well, they take precedence.

In your case, try:

git svn clone \
  --branches=branches/team/releases/* \
  --branches=branches/development/user1/* \
  --branches=branches/development/user2/* \

...etc.

Is it OK to run clone again or to I have to start from scratch and delete the git repo?

Generally speaking you ought to try from scratch. The tool is not meant to be an update script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM