6

I had master dcommit to (and rebase from) the Subversion trunk.

I created an intermediate Subversion branch tc, to merge changes from 2 different branches, using:

git branch master
git svn branch tc -m "Branch for merging"
git checkout -b tcl --track tc
git merge cat #Another branch, whose changes I merged here
git commit -m 'Merged changes from cat branch'
git svn dcommit

Since everything was fine, I wanted to promote this to the trunk. I followed doing:

git branch master
git merge tcl
git svn dcommit

Now, because master was merged from another branch that was pointing to a different Subversion branch, it tries to commit to the Subversion branch tc. I want it committed to the Subversion trunk.

Is there a git svn switch or something like that?

I know my workflow is not the optimal and any suggestions to improve it are welcome too.

Daniel Hershcovich
  • 3,751
  • 2
  • 30
  • 35
lprsd
  • 84,407
  • 47
  • 135
  • 168
  • 1
    I don't know the answer to your question, but one thing I highly recommend is to always do a `git svn dcommit -n` (dry run) before doing the actual dcommit. One reason for that is so you can make sure you're committing to the svn branch you mean to commit to. – Tyler Jul 21 '11 at 07:58

2 Answers2

4

As mentioned in this question, using git merge in a repository with git-svn is not a good idea.

Instead, what you should have done to "merge" the changes into master is:

git checkout master
git format-patch --stdout master..tcl | git am
git svn dcommit

The problem with git merge in this case is that it also sets the git-svn URL for master to the SVN tc branch. The format-patch and am combination only takes the changes themselves.

Community
  • 1
  • 1
Daniel Hershcovich
  • 3,751
  • 2
  • 30
  • 35
  • Would a rebase instead of a merge have the same issue? – RationalGeek Dec 18 '13 at 20:12
  • You should never rebase anything from an svn branch if you want to dcommit it, because you won't be able to. svn does not support history modification. – Daniel Hershcovich Dec 18 '13 at 21:14
  • Well, I won't do it next time. But how does it solve the issue if the problem is already there? – jlengrand Mar 06 '14 at 10:21
  • @jlengrand can you explain your question? If you already merged and you want to dcommit you'll have to `git reset` back to before your merge and re-do it with the above method. – Daniel Hershcovich Mar 06 '14 at 18:02
  • Yes, I had already merged :). I found a solution here http://stackoverflow.com/questions/2835791/git-svn-reset-tracking-for-master in @dyodji answer after a while :). Thanks for the answer though! – jlengrand Mar 07 '14 at 06:56
1

AFAIK a --no-ff merge would have gone the way you want:

git branch master
git merge --no-ff tcl
git svn dcommit
Bruno Medeiros
  • 2,251
  • 21
  • 34