« Python vs Haskell : An unsatisfying exercise in comparative code linguisticsMetric time of day display and conversion »

Switch Subversion to Git: a list of links

09/12/09

Permalink 10:28:59 am, 382 words
Categories: Code, Linguistics

Switch Subversion to Git: a list of links

Now that Josh, a fellow CL student admin, has been using git for at least six months, I feel confident in doing so myself, because now I can just offload complaints and questions to him. Anyway, I've been using subversion for a year or so for very simple one-person source control, but it's a real pain to work from my parent's house with limited internet—I have no interest in installing RIM's USB tethering drivers on my ancient Powerbook. The other option is to come back to school and commit a giant patch that touches every file.

So I want to get back to distributed source control. I used darcs for a few years, but it lost the ability to pull patches to very out-of-date repos in a "reasonable" amount of time. That's scary, so I dropped it completely and went back to subversion. I knew git and hg were both gaining wide support at the time, but I wanted something that was stupidly reliable, and as a one-person dissertation-writing team, I don't need anything beyond revision control really.


Warning: These instructions worked for me on an Intel Mac running OS X 10.5 and a PPC Mac running 10.4 Server. Both have MacPorts installed and working as well as it ever does. In other words, I am not an expert. These instructions may be wrong. This is just the information I used to get git working.


  1. Install git with svn from MacPorts
  2. MacPorts crashed halfway through installing git-svn. It tends to fail a lot. I never got the step 1 instructions to work on PPC 10.4 Server, although this workaround works for Intel 10.5. Do it, *then* (re)run step 1.
  3. If you put the git repo in the same directory as your old svn repo, run git reset --hard, because git otherwise won't touch the existing files.
  4. Since I only had git-svn working on my local machine, I used these instructions to push the repository to the server.
  5. Don't forget to git reset --hard again if the server's directory has the project files already there.

I learned about git reset --hard from the warning git printed and this discussion.

I also found a very nice git crash course for svn users, and instructions on how to use opendiff (aka FileMerge) for viewing diffs on OS X.

4 comments

Comment from: JoshuaHerring [Visitor] · http://jwherring.com/TOWM
Why all the trouble? The Mac installer from the git downloads page works just fine - for the Intel, anyway. And it comes with all the git-svn stuff you need.
09/12/09 @ 15:17
Comment from: sandersn [Member]
I usually try MacPorts first. I know it's stupid, but I do. I ended up using the Mac installer for my laptop that doesn't have MacPorts.

Anyway, MacPorts is only steps 1 and 2 of 5. The other links are also useful even if you use the installer.

I am still trying to figure out how to get my setup working The Distributed Way, with a desktop and laptop pushing to a third repo (jones) that is backed up. It *works* now, but jones complains that I'm messing with the currently checked out branch every time I push something to it. I think I need a separate branch for the other two machines to push to.
09/12/09 @ 15:52
Comment from: JoshuaHerring [Visitor] · http://jwherring.com/TOWM
The trick is to have two copies on your central server - one of which is for pushing, and one of which is actually the repository. Since it's distributed, of course we don't care about having ton(nes) of copies(z). That's what I do for the department webpage anyway.

Here's what I did:

cd into www
git init
git add .
git commit -a -m "Initial Import"
cd ..
git clone --bare www www.git
mv www www.backup
git clone www.git

So now there are two on the dept webpage, and the one internet people see is actually pulled from the other one. All you do then is add a post-update hook in www.git - a simple shell script that cd's to www and does a git pull from there. It should fire any time you make a change to www.git. And of course, on each of your local machines you clone www.git rather than www:

git clone path

I used ssh for the clone to avoid having to deal with Apache and permissions.

All this information is from one of Daniel Miessler's tutorials - but your blogging software doesn't seem to allow html tags in comments, so I haven't included it.
09/12/09 @ 18:10
Comment from: sandersn [Member]
Thanks, that does work much better.

I knew it was a good idea to let somebody else do the work of actually reading a tutorial!
10/12/09 @ 08:53

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
powered by b2evolution