开发者

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

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. 开发者_如何学JAVAEvery 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


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.


Generally what you want to do is not recommended (to say the least: the real statement is more like "don't").

I actually tried to do something similar a while back, where we had an offline git copy of a svn tree that we worked with. While it worked well for keeping track of the upstream SVN changes, it does not work trying to push back into the SVN tree (and forget it altogether if you're doing anything with git branches).

Read the git-svn man page very carefully. It states repeatedly that git-svn != git. Specifically, git-svn << git. Sure, it's better than SVN itself, but it is not safe to treat it as a full "git clone" of a SVN repository where you can do anything you want and push it back.

As an example case, consider a reviewer that needs to make a change. He makes the change, pushes the result back to the git repo, the reviewed change gets checked by the original author, and the original author does the dcommit. Remember that the only SVN authentication is from the git-svn client and thus the original author is the one "submitting the changes to the SVN tree" and thus takes ownership of everything. It gets worse when you get multiple people just committing work to the git repo at the same time. The first person that does the dcommit (if it actually works, and it likely won't) takes ownership of all the changes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜