Git-SVN with multiple branch locations?

前端 未结 3 433
萌比男神i
萌比男神i 2020-12-04 15:53

Our company subversion repo is a bit tricky: We\'ve got a basic \"default\" layout with trunk, tags and branches. However, inside the branches, we have a \"work\" directory

3条回答
  •  忘掉有多难
    2020-12-04 16:34

    You can add multiple branches and tags entries in your git-svn config, even retroactively. So if normally SVN branches live in branches/* in your SVN repo (ie. a standard layout), but you also have branches/summer-students/*, you can set it up in .git/config like below:

    [svn-remote "svn"]
        url = svn+ssh://svn.example.com
        fetch = trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*
    
        branches = branches/summer-students/*:refs/remotes/svn-summer-students/*
    

    On the left of the : is the path in the SVN Repo, and on the right is the path it will appear as in your git remote branch list. You can use refs/remotes/* repeatedly to have everything appear as a top-level remote branch, but watch out for name collisions - they will break things (hence svn-summer-students instead of summer-students, which already exists).

    After you edit the config, you need to delete .git/svn/.metadata and run git svn fetch to refresh the branch list and regenerate it. git branch -r should then show the extra branches. If you get errors, look out for naming collisions.

    The git svn docs have some more examples of specifying paths via wildcards or expressions if you have a funky SVN layout.

提交回复
热议问题