Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to commit into SVN branch after rebase?

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?

like image 259
ownking Avatar asked Feb 17 '10 17:02

ownking


People also ask

What should I do after git rebase?

When you do a Git rebase you take that latest state of the master branch. Then commit by commit your changes are re-added on top of the latest state on master. After each commit is replayed there is a check if there are conflicts which you should then fix, but more on that later.

What does git svn rebase do?

Normally, the "git svn clone" and "git svn rebase" commands attempt to recreate empty directories that are in the Subversion repository. If this option is set to "false", then empty directories will only be created if the "git svn mkdirs" command is run explicitly. If unset, git svn assumes this option to be "true".


1 Answers

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.

like image 116
P Shved Avatar answered Oct 17 '22 10:10

P Shved