Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a bidrectional Git<->Svn Sync (both writable) possible?

Tags:

git

svn

a part of our team found out that git is cool and started using it as a svn client. So every developer had a local git repository and synced it with svn via git-svn.

Then we wanted to do code reviews of the commits and send patches to collegues for review. This approach was not very intuitive, since the checksums of the SAME Revision in svn was different for each local git repository. No clue why, since the content should be the same. Maybe it is a bug in svn rebase?

So we tried to have a central git repository on the scm server. Every developer that uses git now could push his changes to this central repository and the other developer doing the review could pull those into his repo. Unfortunatelly because every developer also synced with svn rebase the checksum problem was there again.

After reading many posts I think the best way to manage a team with both subversion and git clients is to have:

  1. A central Subversion repository
  2. A central Git repository (origin)
  3. A central Git working copy on the server
  4. For each git developer a local git repository
  5. For each svn developer a ordinary working copy

Now we need a central job to sync svn with git doing a regular script like this on a central git working copy on the server.

# First transfer the commits from git to svn
git checkout svnmaster
git pull origin svnmaster
git svn dcommit

# Now from svn to git
git svn rebase
git push origin svnmaster

My questions now are:

  1. Is this the best approach (without switching to git completeley)
  2. Are there already scripts for windows doing the sync bullet proof?
  3. Is the problem with the different checksums known and is there maybe a workaround known?

Thanks for every answer!

EDIT I recently found a project that looks very promising:

SubGit

like image 425
schoetbi Avatar asked Mar 09 '11 05:03

schoetbi


1 Answers

There is problem with your solution. I recommend you not to commit in svnmaster directly. You should have one pure git branch for svn(svn-dev), and svn tracking branch(svn-master). Follow these steps to commit to svn:

git checkout svn-master
git merge --no-ff svn-dev
git svn dcommit
git checkout svn-dev
git merge svn-master

This sequence allows you to preserve commit hashes for all repositories.

like image 95
gor Avatar answered Oct 02 '22 13:10

gor