Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does git svn dcommit determine where to commit to?

Tags:

git

branch

svn

I'm using git-svn to track multiple branches in the same svn repository. Usually this works fine, but today I've done some resets and rebases, and suddenly my branches wouldn't dcommit to the right remote branch anymore:

$ git branch
* master
  a
  b

$ git svn dcommit -n
Committing to svn://server/repo/trunk ...

$ git checkout a
$ git svn dcommit -n
Committing to svn://server/repo/branches/a ...

$ git checkout b
$ git svn dcommit -n
Committing to svn://server/repo/branches/a ...

So the branch b would commit to the branches/a directory instead of the branches/b directory.

I've tried changing the branch that is tracked:

$ git branch --set-upstream b remotes/b

And other things, but the only solution that worked was to delete the branch b and recreate it:

$ git branch -D b
$ git branch b remotes/b
$ git svn dcommit -n
Committing to svn://server/repo/branches/b ...

Now my question is: how does git svn determine what directory to commit to? And how do I modify this directory?

Thanks,
Jonas

like image 504
Jonas Wagner Avatar asked Aug 31 '10 13:08

Jonas Wagner


1 Answers

The SVN configuration you are looking for is in the .git/config file of your cloned repository. It can be manipulated with a text editor. Here's a sample:

$ cat .git/config        
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[svn-remote "svn"]
    url = https://pdfsam.svn.sourceforge.net/svnroot/pdfsam
    fetch = trunk:refs/remotes/trunk
    branches = branches/*:refs/remotes/*
    tags = tags/*:refs/remotes/tags/*

The branches are assumed to match name-to-name by default. To track a mismatched branch name, either rename the local branch or add an explicit configuration (remote) for the oddly-named branch:

[svn-remote "weirdbranch"]
    url = svn+ssh://ambientideas.com/svnrepos/myproject/branches/myweirdbranch
    fetch = :refs/remotes/git-svn-myweirdbranchlocalname

Additionally, if performing Git merges of branches from multiple SVN repos, the dcommit will (logically, but confusing to first time users) target the SVN URL of the first merge commit parent. The Git documentation states "git svn dcommit will attempt to commit on top of the SVN commit named in git log --grep=^git-svn-id: --first-parent -1"

If rebasing one SVN branch against another, this means that the "newest" commits (the subordinate branch) will be the target of the dcommit. Frequently, the user wants to target the dominant SVN repo (branch). This requires the user to use the --no-ff option when rebasing to ensure the last commit points to the dominant branch (new cherry-picked commits).

Other relevant StackOverflow questions include:

  • Switch the svn branch git dcommits to
  • Getting git svn to dcommit master to trunk again
  • git-svn: reset tracking for master
  • Why is git-svn trying to use an old branch point?
  • http://git-scm.com/docs/git-svn
  • git-svn isn't committing to branches, only trunk
  • Git-SVN with multiple branch locations?
  • Cloning a Non-Standard Svn Repository with Git-Svn
like image 154
Matthew McCullough Avatar answered Oct 26 '22 20:10

Matthew McCullough