1

I followed this post on how to create and checkout a branch using git svn so that the branch was actually created on the svn repos. This worked great.

When I was done with my branch, I did a checkout on master and did a git merge. This worked fine. I then went to commit the merge back to the trunk on the svn repos so issues a git svn dcommit.

And it tried to commit to the branch. Even though I now have the master branch checked out. What am I missing?

$ git svn branch -m "test branch" test_branch
$ git checkout --track -b test_branch remotes/test_branch
$ Hack hack hack...
$ git svn dcommit --dry-run    # Make sure you're committing to the right SVN branch
$ git svn dcommit              # Commit changes to "test_branch" branch in SVN
$ git checkout master
$ git merge test-branch
$ git svn dcommit # why is this committing to the branch instead of trunk??

This is my .git/config in case it matters

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[svn-remote "svn"]
    url = mysvnrepos.com/svn/project
    fetch = trunk:refs/remotes/git-svn
    branches = branches/*:refs/remotes/*
[branch "test_branch"]
    remote = .
    merge = refs/remotes/test_branch
Community
  • 1
  • 1
Gregg
  • 34,973
  • 19
  • 109
  • 214

1 Answers1

0

I thought someone asked this already, but I can't find it again. Anyway, git-svn with branches is complicated. You must create empty branches on the svn side, with git svn branch or plain svn mkdir. Then you check out those branches with git, and rebase commits on top of them without using git-level merges. This way the git branches have the right svn branch indicated in their ancestry, and dcommit commits to the correct branch. You can verify the branch git-svn would commit to using git svn info.

Tobu
  • 24,771
  • 4
  • 91
  • 98
  • That's all great for the future, but I need to fix what's happening now that I've apparently not done it right. – Gregg Jun 28 '11 at 18:07
  • @Gregg `git checkout master; git rebase test_branch` will eliminate the merge commit which should restore order. – Tobu Jun 28 '11 at 18:14
  • It did not. I did both of those commands, then a git svn dcommit --dry-run. Still says it is Committing to my branch. – Gregg Jun 28 '11 at 18:39
  • `rm .git/svn/refs/trunk/.rev_map.*` and try again? – Tobu Jun 28 '11 at 18:48
  • No go. I'm going to scrap it and start over just so I can keep working. The branch didn't have much in it because I was just using it to test. But I'm still very curious of how I might fix this. – Gregg Jun 28 '11 at 18:53