Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've got a 'git-svn' working tree. I'd like to clone a "pure" git repo off this, and then use git push/pull to move changes between the git-svn tree and the git tree, while also using 'git svn dcommit/rebase' to move changes between the git-svn tree and the SVN repo it's based on.

This seems to work okay as far as moving things back and forth between the git trees using git methods, but as soon as I interact with the SVN repo in the git-svn tree, things get wonky -- either I get errors when pushing or pulling between the git trees, or I lose commits in the git-svn tree, or other oddness.

Is this type of SVN <-> git-svn <-> git workflow supported at all or should I just quit barking up this tree?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
767 views
Welcome To Ask or Share your Answers For Others

1 Answer

I have a bridge setup for some of my projects, but it's only one-way from git to svn (providing a public readonly SVN mirror of our git master branch). However, since it works fine it might help you or point you in the right direction in your two-way scenario anyway, as I assume it's git->svn that makes problems, not svn->git:

My one-way scenario: Existing git repository at github, need a readonly svn mirror of the git master branch

  • Create and initialize the target subversion repository on the Server:

    svnadmin create svnrepo
    mkdir trunk
    svn import trunk svn://yoursvnserver/svnrepo
    rmdir -rf trunk
    
  • Create a mixed Git-Svn checkout and initialize subversion repository

    git svn clone svn://yoursvnserver/svnrepo/trunk
    cd trunk
    git remote add github git://github.com/yourname/repo.git
    git fetch github
    git branch tmp $(cat .git/refs/remotes/github/master)
    git tag -a -m "Last fetch" last tmp
    INIT_COMMIT=$(git log tmp --pretty=format:%H | tail -1)
    git checkout $INIT_COMMIT .
    git commit -C $INIT_COMMIT
    git rebase master tmp
    git branch -M tmp master
    git svn dcommit --rmdir --find-copies-harder
    
  • Update the mirror

    git fetch github
    git branch tmp $(cat .git/refs/remotes/github/master)
    git tag -a -m "Last fetch" newlast tmp
    git rebase --onto master last tmp
    git branch -M tmp master
    git svn dcommit --rmdir --find-copies-harder
    mv .git/refs/tags/newlast .git/refs/tags/last
    

This two articles from googlecode might help as well:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...