2017-12-02 396 views
1

如何在GIT庫和SVN庫之間進行雙向同步?我已經看到了如何從SVN轉換爲GIT,但沒有太多關於如何在兩者之間順利同步。如何在GIT和SVN之間進行雙向同步

目的是將項目保存在兩種類型的存儲庫中,並讓它們生成/跟蹤相同的內容。

作爲一個額外的要求,作爲主題的SVN存儲庫不包含主幹和分支。

回答

3

爲了確保SNV和Git存儲庫之間真正的雙向同步,您需要一個專用的第三方工具。

我只知道SubGit能夠做到這一點可靠。但它不是免費的。只有從SVN到Git的一次性遷移是。

0

這篇文章 - Creating a two way sync between a Github repository and Subversion - 看起來是一個解決方案:

  • 創建一個GitHub的服務器或服務器到位桶上一個混帳回購協議。克隆空回購。添加一個readme-git文件並在master上提交。

  • 最初創建SVN跟蹤分支:

 
    git branch --no-track svnsync 
    git checkout svnsync 
    git svn init http://your-svn-server/your-repo 
       # here removed `-s` if the svn repo is not on a standard layout 
       # or use file:///path/to/local/repo 
    git svn fetch 
       # add if needed `--authors-file svn-authors.txt` 
    git reset --hard remotes/git-svn 
       # the post said `remotes/trunk` but it does not look right 
  • 同步從SVN到混帳:
 
    git checkout svnsync 
    git svn rebase 
    git checkout master 
    git merge svnsync 
       # add `--allow-unrelated-histories` to the first merge 
    git push origin master 
  • 同步從GIT中的svn:
 
    git checkout master 
    git pull origin master 
    git checkout svnsync 
    git svn rebase 
    git merge --no-ff master 
    git commit 
    git svn dcommit 

上述順序的一個缺點是添加了僞造的readme-git文件,因此可能會拉出非跟蹤分支。我想,從最初從svn回購克隆的git回購開始,可能會避免這個問題。

+1

是的,它可以用於簡單的回購/分支機構,但是SubGit編寫的角落案例太多以致於無法解決這些問題。 – VonC

相關問題