views:

382

answers:

8

For programming in my spare time, I have both a desktop and a laptop (both Macs, though I doubt that makes a difference the question). I've got VMware on both of them, with Linux images to run my code on. They're identical images, so I've got the same environment in both places.

The trick is that I like to use version control for ALL my coding, even when I'm not coordinating with someone else. I want to see the most recent version of my code on whichever system I'm using.

I don't want to depend on having network access at all times - I might be coding somewhere without wi-fi (yes, it's rare, but some places are still in the stone ages). I'm looking at using git, but something like SVN would also do if I had the repository available locally. Or maybe the laptop becomes the SVN server and the desktop accesses it.

Has anyone done this kind of thing before? Any traps/pitfalls/lessons learned?

+7  A: 

I would highly recommend git if you won't have network access at all times.

However, if you still need to work with subversion repositories, you can still get the best of both worlds by using git-svn.

ern
Git-svn or just an off-site git repository (like github) you can push to. You probably want to have a back-up somewhere other than your laptop.
Darcy Casselman
I disagree that you get the best of git when using git-svn. It's much better than trying to use svn without git, of course.
Dustin
+2  A: 

Whatever you do, make sure your repository is backed up regularly. This is especially true if your laptop houses your repository. You'll also want to think about what happens if your laptop gets stolen. It might be better to use git and leave the repository on the desktop.

tvanfosson
I'd definitely do something to make sure it's backed up offsite. Perhaps a cron job to sync it to my iDisk frequently, or copy the repo to my desktop (which is backed up) regularly.
edebill
A: 

SVN becomes pretty awkward to use when you don't have access to the repository. Since I do all my development on one computer, I've gotten by fine with SVN, but you might not find it so easy. From what I've heard, that's exactly the kind of problem that git is designed to deal with - it lets you make commits that are registered in your local copy, then upload them all to the repository when you get access to it.

David Zaslavsky
A: 

You could consider getting an SVN host - they are fairly affordable and take the headache away from having to deal with your own network connectivity:

http://www.google.com/search?hl=en&q=svn+hosting&btnG=Google+Search&aq=f&oq=

Chance
Or just get a regular web host that offers SVN as a feature.
Kibbee
Unfortunately, this won't work if I'm working somewhere without immediate network access.
edebill
+1  A: 

As an alternative to Git, which has already been mentioned, I would highly recommend Bazaar. It is a distributed VCS as git is, with some differences though.

For a (somewhat biased, of course) comparison, check out this page.

Simon Jensen
I'd second this. Bazaar suits my taste for usability better than git, but it's effectively a wash, I think.
Darcy Casselman
@Darcy, agreed. One notable difference though, is the effort put in supporting Windows (which doesn't seem relevant for the OP though).
Simon Jensen
Nope. Not relevant. I need MacOS support and Linux support, though. Sounds like I should investigate Mercurial and Bazaar (I've already tried git).
edebill
+5  A: 

Well, I'd definitely recommend looking at a distributed system instead of Subversion. That will satisfy your requirement of not being dependent on network access, and probably just fits your workflow better. The major choices for a distributed VCS are git, Mercurial (also referred to as "hg"), and Bazaar (or "bzr"). My personal preference is Mercurial, but they're all fairly comparable.

However, one thing that Mercurial does have over the others (and it's something that would be very helpful in your situation) is the "hg serve" command. You can read about it here: Informal sharing with "hg serve". Basically it sets up a very simple (temporary) server to allow pulling your repository over the network. I use this all the time to keep code synchronized between my desktop and laptop. If I've made some changes on the laptop, I just run "hg serve" on there and then "hg pull" from the desktop, or vice versa if I've been working on the desktop.

So overall, I'd definitely suggest looking into the distributed systems, I think they'll do the best job of setting up the sort of environment you want. There's a fair amount of information available on the web about using all of them. I haven't spent much time with the others, but if you want to try Mercurial, this free online book covers pretty much everything you'll need to get started.

Chad Birch
Sounds like you're the only person who's actually done this in some way.My concern with going truly distributed is that I'll have to merge back and forth between the computers, which is a recipe for me forgetting to merge things. Any magic fix for that?
edebill
Well, any VCS is going to require you to remember to commit/update, so there's not really anything that can get rid of that. Merging in all the DVCS systems is very good, so you shouldn't really have to consider this as a difficult task.
Chad Birch
Unless for some reason you've changed the same code in a different way on the separate machines (and your memory is probably better than that), there should never be any merge conflicts, and everything will get merged together automatically without any interaction needed.
Chad Birch
For the record, Bazaar has a bzr serve command too, and can synchronize over FTP, HTTP and some other protocols.
PhiLho
+1  A: 

If you are after simplicity (setup), SVN is fine. It works without network connectivity because your entire history is kept on every sync'd PC, and SVN+SSH is TRIVIAL to set up. It uses the built-in ability of SSH to run a program, so if you have an SSH server set up, you just create a repository and everything works.. no server setup whatsoever.

This can also act as your backup since you have your entire repository on every computer you sync with.

Distributed version control systems are interesting as well, but I think the upfront investment is higher but it has the advantage that you can save to your repository without being connected (not too critical if you are working alone, but being able to checkpoint and rollback anywhere can have it's advantages).

Bill K
That simplicity was part of why running an SVN repo on the laptop seemed tempting. Since I'd always either be local or guaranteed to have the laptop available there would never be a problem getting to it.By only having 1 repo I wouldn't have to merge with myself.
edebill
Try SVK, I hear it's supposed to be nearly as simple, but also always have a local repository. No first hand experience though.
Bill K
A: 

My favourite VCS is darcs since it supports patch cherry-picking. It is a distributed VCS and it is VERY easy to use.

Johannes Weiß
git and mercurial have excellent support for cherry-picking as well. :)
Dustin
But as far as I know, that is not possible with git and hg: repo A contains patches 1, 2, 3 and 4; repo B contains patches 1, 5, 6; repo C contains nothing. With darcs I can now pull patch 1, 2, 4 from A and 6 from B, so that C now contains 1,2,4,6 and A und B remain unchanged.
Johannes Weiß
Ah and one important addition: I can later unpull any patch, now only the last! There are no versions in darcs.
Johannes Weiß