1

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

That sucks, but it makes sense. The commits uniqueIDs don't correlate so it sees them as two different histories.
I would think that a repository uses git-svn to clone and all other git repositories use that as their origin, it should work. This repository would be the weak link though, as it would need to be maintained and if lost, a git-svn reclone and reclone of all other git repositories would be necessary.
@user197766: The git-svn repo would still be rebased regularly (git svn rebase) - that would confuse the other git repos that use it as their origin. Yes, there are ways to cope, but they are not simple.
I think you've answered my question, but I'm trying to make sure I understand the why. Is it because rebases are history changing and shouldn't be done with shared branches?
@user197766: Exactly. This is called an "upstream rebase", and is generally considered a bad idea. There are ways to work with upstream rebases (the manpage for "git rebase" has a section about this), but git does not (and to some extent cannot) support upstream rebases well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.