Search code examples
gitgit-svn

Which remote branches are my local git-svn branches bound to?


I have the following .config file in my clone repo using git-svn:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[svn-remote "svn"] 
    url = https://svn.domain.com:8443/svn
    fetch = trunk:refs/remotes/trunk
    branches = branches/{some_branch}:refs/remotes/branches/*

When I do git branch -a, I get:

$ git branch -a
* master
  remotes/branches/some_branch
  remotes/trunk

How do I know which remote the local master branch is bound to (tracking)? Note that it seems this answer must be specific to git-svn since the normal git solutions (e.g. git remote show origin) do not work.

EDIT
After reading my question more closely I am not sure it makes sense. Basically I just want to know which SVN branch 'master' is bound to. I assumed remotes were branches, but they are actually just URLs to other repos AFAIK. So, what I really want is the mapping between remote SVN branch & local branch.


Solution

  • what I really want is the mapping between remote SVN branch & local branch.

    The answer is: There is none (at least not in the usual sense).

    To elaborate:

    Normally, in git you have two types of branches

    A local branch can be linked to (and a copy of) a remote-tracking branch (possibly with changes) - then the remote-tracking branch is called the "upstream branch" of the local branch. This "upstream relationship" is stored in the repo config (.git/config), and is visible in the output of git branch -vv.

    Now the thing is: git-svn does not have this concept of an upstream branch.

    In particular, it does not store an upstream relationship in the git config, and thus commands like git branch -vv cannot show it.

    git uses the "upstream branch" to decide where to pull from and where to push to (more or less; it's configurable).

    git-svn, in contrast, simply goes back in the history of the local branch to the latest commit that came from SVN (the latest commit with a "git-svn-id"). That commit will also name the SVN branch (i.e. path in the SVN repo) that it was created from (it's part of the string after "git-svn-id"). git-svn will then use that SVN branch.

    This is described in the git-svn manpage:

    Note the following rule: git svn dcommit will attempt to commit on top of the SVN commit named in

    git log --grep=^git-svn-id: --first-parent -1

    It's not noted in the manual, but I believe that git svn rebase uses a similar rule.