Question

I've been trying all day to configure by hand a git repository locally based on a very large remote subversion repository. It has the default configuration (trunk, branches, tags) but I only want a small portion of the data.

I don't fully understand Git's :refs/remotes/* syntax in .git/config, even though many posts online have explanations for editing it and fetching.

I have my svn repo stored to an $SVNR environment variable. It's roughly equal to https://svn.ourserver.com/svn/

I want a git master branch to track $SVNR/branches/production and a development branch to track the remote svn trunk.

I have a huge repo and only want a few revisions, and to construct my git repo to be much smaller subset of the remote SVN repo, like so. Following lots of other sites and posts about doing this, I ended up with this so far as my clone command:

git svn clone -r2000:HEAD --prefix=svnrepo/ --authors-file=/Users/phpguru/Sites/authors.txt $SVNR/branches/production gitrepo

Now I can cd gitrepo and see my .git/config

[svn-remote "svn"]
    url = https://svn.ourserver.com/svn/projectfoo/branches/production
    fetch = :refs/remotes/svnrepo/git-svn
[svn]
    authorsfile = /Users/phpguru/Sites/authors.txt

Now lets take that apart for a moment. Why isn't master listed here? Where did git-svn come from? That doesn't exist in my SVN repo. I don't understand why the fetch ref doesn't say fetch = master:refs/remotes/svnrepo/branches/production ? Can I change "svn" to "projectfoo" as so many examples show?

When I do a git svn info and git branch -a I do see a master branch. It appears that master is properly tracking branches/production as I wanted.

My question is, how do I now create a development branch that is tracking the remote trunk?

I've tried a dozen different ways, including editing .git/config with some logical fetch lines:

fetch = branches/*:refs/remotes/svnrepo/branches/*
fetch = development/*:refs/remotes/svnrepo/trunk/*

but nothing worked.

$ git branch --track development remotes/svnrepo/trunk
error: the requested upstream branch 'remotes/svnrepo/trunk' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.

Or,

$ git branch development --track remotes/git-svn-trunk
fatal: Cannot setup tracking information; starting point 'remotes/git-svn-trunk' is not a branch.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top