me and my git-svn

April 3rd, 2008

I recently switched a bunch of my projects over to git. Why? All the cool kids are doing it, I figured I'd give it a shot. Either way I ran into a few bumps with the git-svn stuff. Everything went really well until I tried to push back my changes from git. I'd been committing changes to my repo and pushing them to github/hasno without issue. I ran into errors when I tried to git-svn dcommit.

Here's what I'm currently calling the right way, as usual ymmv:

  1. init if you haven't done i already, check .git/config for an svn-remote entry...
    git-svn init <repo url>
  2. pull the svn revision information. a bunch of info should scroll by matching svn revisions to git sha1 revisions.
    git-svn fetch
  3. this will yeild a list of local & remote branches, you should see trunk in the list
    git branch -a
    * master
      origin/HEAD
      origin/local-svn
      origin/master
      tags/release-0.1.23
      tags/release-0.2.42
      tags/release-0.2.44
      tags/release-0.2.50
      trunk
       
  4. switch to a local branch based on the trunk remote branch
    afaik you really don't want to be doing any of this type of stuff in a remote branch
    git checkout -b local-svn trunk
  5. now we need to pull your local changes from your master branch to your local-svn branch
    git merge master
    it's worth noting that you could do a git rebase, but when I tried that I couldn't use git-svn dcommit
  6. go through and merge any conflicts. then git commit. at this point you can git dcommit

So if all that was how I got it working, what did I run into along the way... Well I'm glad you ask. Here's a list of errors and the reason for them afaik:

Unable to determine upstream SVN information from HEAD history
You have a recent commit that doesn't have any history in .git/ref/remote/svn or .git/svn. It also doesn't have the git-svn-id: key in the commit message.
[svn-remote "svn"] unknown
Did you manually create the svn-remote entry, or specify a different name? If so you need to pass that on to the commands, they seem to assume it's named svn.
fatal: bad default revision 'refs/remotes/git-svn'
Somethings amiss with your svn-remote entry in .git/config

That's about it for me, if you've seen those errors and can add some detail or shed some light on a better way please do share. As of this moment ruby-hl7 is synched up.

1 Response to “me and my git-svn”

  1. valentin valentin Says:
    I think that your problem is that the master branch, in which you have committed the changes, was not tracking a remote branch. When you clone a SVN repo, it is a good idea to call git reset --hard remotes/trunk when you are in the master branch. This way the master branch will track the trunk remote branch in SVN and you should be able to dcommit. Just my thought. I am also pretty new to git and git-svn.

Leave a Reply