Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I git-svn clone an svn repo with multiple standard directory layouts

Tags:

git

svn

git-svn

I have an SVN repo with a layout like
project1/trunk
project1/branches
project1/tags
project2/trunk
project2/branches
project2/tags
etc.

For a number of reasons, I'd like a git-svn repo that allows me to work on any of these projects and fetch/dcommit from/to all of them at once. Is this kind of thing possible? I know I could just git-svn clone the whole thing without specifying branches, tags, and trunk, but then I'd lose a lot of the advantage of using git.

like image 855
Shea Levy Avatar asked Apr 01 '11 02:04

Shea Levy


People also ask

How do I clone a SVN repository?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...

What does Git SVN clone do?

The git svn clone command transforms the trunk, branches, and tags in your SVN repository into a new Git repository. Depending on the structure of your SVN repo, the command needs to be configured differently.

Can I use Git for SVN repository?

Use git-svn, it is really simple. First clone your repository with git svn clone then you can git svn dcommit your work or git svn rebase it on the latest changes. Make sure your history is always linear by always rebasing your local branches on master so that you can merge them with git merge --ff-only .


2 Answers

This is how I did it. There may be simpler ways, though.

  1. Select the first project with the standard layout you'd like to work on and git svn clone it:

    git svn clone --stdlayout http://sample.com/svn/repository-name/project-name repository-name

  2. Go into the repository-name directory and edit its .git/config file. You could also do this with git-config commands, but I find it easier in a text editor.

  3. You'll see an [svn-remote "svn"] section already defined for your first project. Rename the svn-remote to something more unique than "svn", probably the same as your project name. E.g., [svn-remote "project-name"].

  4. Make more [svn-remote "project-name"] sections for each project, following the template of the first one. Give each one a unique name! You'll need to change the fetch, branches, and tags settings to use the correct Subversion directory names for each project.

  5. Once you're done, save your file and run git svn fetch --fetch-all. The other projects will be fetched as remotes in your local repository.

  6. To switch your master between projects, do a git reset --hard other-project-name/trunk, just like if you were switching to work on any other remote Subversion branch.

like image 141
Mark Gardner Avatar answered Nov 11 '22 07:11

Mark Gardner


To get around the issue of checking out multiple projects simultaneously, git-new-workdir can be used to check out multiple working directories from the same git repository, see https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir

like image 45
Ethan Avatar answered Nov 11 '22 05:11

Ethan