How (not) to retrofit a repo connection to svn

From Bitpost wiki
Revision as of 17:08, 29 January 2008 by M (talk | contribs) (New page: Let's set up a repo on a second client that uses the public repo. There are two ways to go: set up just like we did the first client, by starting with a grab of the svn repo and branching...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Let's set up a repo on a second client that uses the public repo. There are two ways to go: set up just like we did the first client, by starting with a grab of the svn repo and branching it, then connecting it to the public repo; or set it up using the public repo, then connect it to svn. Let's be nice and try to set things up without having to hit the svn repository again.

ssh client2
cd my_git_repos
git clone ssh://server/git_public/mythtv mythtv

Now you've created a clone of what was checked into the public repo from client1. The master branch is automatically created and associated with the master branch in the public repo. We need to create and associate mybranch with the one in the public repo. First, create it:

git checkout -b mybranch

Next, we associate it to the public mybranch by editing the .git/config file (don't worry, you're supposed to! and it's easy...). Here's what associates the master branch to the public repo (it's already in the config file):

[branch "master"]
       remote = origin
       merge = refs/heads/master

Add a similar entry for mybranch:

[branch "mybranch"]
       remote = origin
       merge = refs/heads/mybranch

Now when you pull from or push to the public repo, both branches will automatically get synched. Try it now if you like (although you're already up-to-date):

git pull

Note that the connection to svn has not been carried over from repo1. That is, your repo2 is only associated with your public repo so far. That's fine if you're just going to pull svn changes from repo1 and push to your public repo, then pull to repo2. But that's no fun! We can set up all of your repos to be able to sync with the public repo and svn. Let's edit the .git/config file again, re-adding the svn connection:

[svn-remote "svn"]
       url = http://svn.mythtv.org/svn/trunk/mythtv
       fetch = :refs/remotes/git-svn

Now try a refresh from svn!

git checkout master
git svn rebase

Whoops, it doesn't work! Bummer.  :<