Search code examples
gitversion-controlgit-svngit-remote

Using GIT with both a GIT remote and an SVN remote


My team currently uses svn. I wish to use git for my project and have several remotes that need to work together. I am using a bare git repository for the various git remotes to coordinate. I occasionally need to push my changes up to the svn repository for the team at large. I currently have an existing svn remote and an existing git remote. I used this method to add svn to my pure git clone (from the git remote):

http://www.draconianoverlord.com/2010/03/05/existing-git-into-svn.html

Now, I got everything committing to svn, but when I try to rebase from the git origin, it wants to merge in all of my changes ever and conflicts on everything. Seems every time I want to interact with one or the other, it requires a merge and has conflicts. Is there a way to avoid this? I undid the whole history merge and origin/develop is not anywhere to be seen in my history... (what I'm trying to push to)

Update:

Seems my history was screwed up by this process, basically creating two separate history timelines. All the changes from the svn side conflict with the git side. So, is an svn remote and a git remote incompatible? As, in if I use svn, I have to make it my authoritative remote and that's it?


Solution

  • So, is an svn remote and a git remote incompatible? As, in if I use svn, I have to make it my authoritative remote and that's it?

    In a nutshell, yes. As the manpage explains:

    CAVEATS
    
           For the sake of simplicity and interoperating with Subversion, it is
           recommended that all git svn users clone, fetch and dcommit directly
           from the SVN server, and avoid all git clone/pull/merge/push operations
           between Git repositories and branches. The recommended method of
           exchanging code between Git branches and users is git format-patch and
           git am, or just 'dcommit’ing to the SVN repository.
    
           Running git merge or git pull is NOT recommended on a branch you plan
           to dcommit from because Subversion users cannot see any merges you’ve
           made.
    

    So yes, to keep things simple when using git svn, the SVN repo should be your only upstream repository.

    There are ways around this, but they are complex and require good knowledge of the internals of git and git-svn, so generally you should stick to the advice above.