views:

187

answers:

2

I have a problem with a SVN branch. I made a checkout of it with git checkout -t -b stable svn/stable. Then I did a merge with git rebase master. After that I tried to commit the merge changes into the remote branch with git svn dcommit

But now it seems, that Git pushed the changes into the trunk instead of the branch :(

And git status tells me:

# On branch stable
# Your branch and 'svn/stable' have diverged,
# and have 218 and 52 different commit(s) each, respectively.
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
...

Does somebody know what I did wrong and how to do it right?

+2  A: 

I recently hit the same error. The thing is that when you rebase to master, it first hard-resets current branch to master and then applies commits being merged to it. But your master branch is associated with svn/trunk and thus the newly reset branch becomes associated with it as well. So git-svn on dcommit thinks that the commits are "inserted" into svn/trunk when you push them.

The solution is to use git merge --no-ff instead of git rebase. Or to use merge facilities of Subversion itself.

Pavel Shved
Hmm thanks, I know about the possibility to use git merge, but then I'll loose the revision history and lot of other informations.Will it also be a solution to rebase with a branch of master instead of the master itself?
@tigerseye, I doubt that such branching tricks will help you. since the commit that's associated with `svn/trunk` will get into your branch anyway.To keep revision history, you can merge with Subversion. Otherwise, you'll just pollute subversion log and other developers will not be happy with that.
Pavel Shved
I'm new to git and I realy see the advantages but in this eary steps it feels sometimes too difficult for the daily challenges.Isn't it a common scenario in the git switchers world to merge a dev git branch into a stable SVN branch whatfor there exist a common way to do this?
You can merge git branch to svn branch, if that git branch was branched from the *same* svn branch a time ago. But in your case you're trying to merge one "svn branch" into another "svn branch", but do it with git facilities in a git way, not in svn way! That's different!
Pavel Shved
A: 

Now it works, I did it like this:

   git checkout master
   git svn rebase
   git checkout --track -b svn_stable svn/stable
   git merge --squash master
   git commit -m "Bring stable up-to-date with trunk" 
   git svn dcommit --dry-run
   git svn dcommit

The merge was much easier than rebase with conflict handling.

In this try I forgot to use --no-ff, this forces a commit for each merge, right?

Thanks for your help :)