简体   繁体   中英

Version control to coordinate with yourself

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?

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 .

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 .

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.

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 .

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).

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.

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=

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM