Search code examples
git-svn

What is the Difference Between fetch and branch in the Git config file


The config file of a Git repository has under [git-svn remotes] both fetch and branch paths. The config file can even have multiple fetch lines and multiple branch lines. What is the reason to have (and what is the difference between) both fetch and branch? When I do a git svn fetch --all, I get updates for the trunk in fetch and from all the other branch lines as well. So it seems there is no difference. Is there any drawback if I just list all my branches using multiple branch and not have any fetch line?

[svn-remote "messy-repo"]
    url = http://server.org/svn
    fetch = trunk/project-a:refs/remotes/project-a/trunk
    fetch = branches/demos/june-project-a-demo:refs/remotes/project-a/demos/june-demo
    branches = branches/server/*:refs/remotes/project-a/branches/*
    branches = branches/demos/2011/*:refs/remotes/project-a/2011-demos/*

Solution

  • As illustrated here, the first git svn clone does generate a cnfig with fetch in it.

    If at any point after this you want to checkout additional branches, you first need to add it on your configuration file:

    [svn-remote "svn"]
      url = https://example.com/
      fetch = PROJECT/branches/somefeature:refs/remotes/trunk
           branches = PROJECT/branches/{anotherfeature}:refs/remotes/*
    

    The branches config always needs a glob.

    From git svn clone

    After a repository is cloned, the fetch command will be able to update revisions without affecting the working tree

    The difference:

    It is similar the core Git [remote] sections except fetch keys do not accept glob arguments; but they are instead handled by the branches and tags keys.