There is any way to synchronize GIT and Subversion repositories?

后端 未结 7 553
花落未央
花落未央 2020-12-23 10:17

I want to access a repository using both GIT and SVN clients. A way I imagined to do that is through automatic two-way migration: when a user PUSHes into the GIT repository,

7条回答
  •  清酒与你
    2020-12-23 10:33

    I have a bare-git central repos + SVN-git bridge - a repos with git svn, tracking SVN in branch 'current' and tracking GIT repository in branch 'gitcentral'

    Then I use post-update hook in central git repos like that:

    #!/bin/bash
    
    # Anything inserted into GIT - move it back to SVN
    
    echo
    echo '* Pushing data into SVN branch'
    cd /home/git/BRIDGE
    unset GIT_DIR
    
    # current - svn branch locally and central git branch on project.git repos
    # centralgit - unmodified centralgit branch
    git fetch /home/git/repositories/project.git/ master:centralgit || (echo "Error while pulling data into bridge repository"; exit 1)
    git checkout -b temp centralgit || exit 2
    git rebase current || exit 3
    git checkout current || exit 4
    git reset --hard temp || exit 5
    git svn dcommit || exit 6
    git branch -D temp || exit 7
    
    echo '* Pushed correctly data into SVN'
    exit 0
    

    That's mostly temporal, but works...

提交回复
热议问题