tags:

views:

175

answers:

3

I'd like to get a local GIT repository in sync with both a remote GIT and an SVN repository.

The steps I'm executing are the following:

> git push
Everything up-to-date

> git pull
Already up-to-date.

Alright, my remote GIT repos seems to be fine so far.

> git svn rebase
First, rewinding head to replay your work on top of it...
Applying: Fixing some javadoc problems.
Using index info to reconstruct a base tree...
<stdin>:13: trailing whitespace.
\t
<stdin>:21: trailing whitespace.
\t\t\t\t<configuration>
<stdin>:22: trailing whitespace.
\t\t\t\t\t<links>
<stdin>:23: trailing whitespace.
\t\t\t\t\t\t<link>http://java.sun.com/javase/6/docs/api/&lt;/link&amp;gt;
<stdin>:24: trailing whitespace.
\t\t\t\t\t</links>
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging lilith-parent/pom.xml
I replaced tabs with \t for clarity.

That's a merge I've already done, previously...
I now have a new local version.

> git svn dcommit
[commits the new version to SVN... again...]

Now master and trunk are both at the head of my local repository.

> git push
To ssh://[email protected]/gitroot/lilith/lilith
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'ssh://[email protected]/gitroot/lilith/lilith'

This means, AFAIK, that I have to execute a pull first. Soooo....

> git pull
Already uptodate!
Merge made by recursive.

which puts me back to the very beginning ... :( Rinse and repeat.

I have the feeling that I'm missing some quite important point here. Can anyone explain this to me?

+4  A: 

One branch can not be tracked both with svn via git-svn and with git via push/pull. You should make these two branches separate and do git rebase on synced branches locally, when you want to transfer commits between these branches

Pavel Shved
Thanks for the info. "Can't be done like that" was all that I needed to know.
Huxi
+4  A: 

The biggest clue is the error in the push:

! [rejected] master -> master (non-fast forward)

This means that you're subversion branch and your remote git master branch are not agreeing on something. Some change was pushed/committed to one that is not in the other. Fire up gitk --all, and it should give you a clue as to what went wrong - look for "forks" in the history. Look out for the branches [origin/master], [master] and [trunk]. The origin could well be on a different branch to your current master - git svn rebase can cause that.

Generally if you are committing via svn and git, you're better off keeping the git master branch identical to the subversion one and working on another branch in git. See this other SO question about working with git and subversion.

rq
I just wanted to thank you for the link to the other SO question. It helped me to get some further insight. I had a hard time deciding if you or Pavel should get the answer check and settled for "Pavel was faster". :p Ideally, I'd give both of you the answer check-mark.
Huxi
+1  A: 

You might also want to check out the blog post Best branching practices with git-svn which has some useful tips related to this.

If you want to get rid of the whitespace warnings, execute

$ git config --global apply.whitespace nowarn
sunny256