views:

304

answers:

13

I have a need to code from two computers during the week. What is the best way to sync the two computers (mac)? I've started using source control, like SVN. It works pretty good, except sometimes I check in code that I want to sync but they don't compile and it interferes with other people on the team working on the same project.

I don't want to use branch. It wouldn't make sense to branch every night when I head home from office.

+5  A: 

You could check your code into a branch rather than onto trunk. Then you get all the benefits of version control without disturbing other people with your compile errors.

There is a description of how to branch in subversion here.

Mark Byers
But I woudln't want to branch every night.
erotsppa
@erotsppa: Branching is a fairly straightforward task - it just makes an identical copy of the project (except the copying isn't really done on the server). Luckily you don't have to branch every night anyway - once you've created the branch, you can just switch to that branch when you want to.
Mark Byers
A: 

Try using branches in your svn repository. Or you can use iDisk if you have a MobileMe subscription.

jbworld
Dropbox > iDisk
Sharpie
+4  A: 

Other good ways are Mercurial or GIT.

They're similar to what you are trying to accomplish except these are DSCM (distributed) so you won't need to setup a whole server just for this.

Make sure you do an UPDATE before CHECKING IN your code, and after you UPDATE make sure your project builds.

Pablo Santa Cruz
You can say that they make branching so easy and simple, that you won't mind creating and merging back several branches every day.
Tadeusz A. Kadłubowski
+1 for this too. I only suggested SVN because that's what he's already using and he already has an SVN server setup, so it might be a smaller step for him to learn branching in SVN than a whole new system. But learning git would be worth it. There's also integration between SVN and Git.
Mark Byers
+1  A: 

You should always ensure your code complies before you commit it to SVN. Before you commit, you should do an update and perform any necessary merging. In some teams I know, there is a fine for committing code that cannot be complied.

Extrakun
A: 

There are some simple rules that you should obey if you don't want to interfere with code that needs to be compiled by other developers, too.

  • Create your own SVN branch that only you work on and commit to
  • Whenever a part of your code is ready to be shared with other developers (or ready for release), merge the changes back into the main branch ("trunk")
  • Or if you don't want to use branches: Make sure your program compiles and unit tests succeed before you commit. That way, there will be fewer clashes with other people's code.
AndiDog
I would definitely go with the Branching suggestion. If you don't branch, and instead always wait to make sure your unit tests pass before you commit, you're potentially waiting a long time in between commits, which is a bad habit (the smaller, more granular your commits are, the easier it is to revert changes, and with more commit messages hopefully it documents better).
jbrennan
+2  A: 

Have you tried Dropbox? it basically setup a folder which will go across multiple PC running the application and it saves versions of the files, however i have never tired it in a programming environment

M.Shuwaiee
+1  A: 

With mercurial (hg) or git you do not need a version control server. You can sync through a usb key, bundles sent per mail or a temporarily started server ("hg serve"). This way nobody else would ever know of any version control server and you would not interfere with your team members. Both hg and git can interact with subversion (I don't know how well they do that, though).

panzi
+2  A: 

Use something like Microsoft Foldershare (now called Live Sync). It's free and works well on Macs.

Don't use source control for this. On my Mac, I've used Microsoft's FolderShare in the past, and it works really well. Whenever I save a file, within 2-3 seconds the changes are propagated to all synced machines. The only caveat is that there is no cloud, so both (or at least one permanent) machines must be online at the same time. FolderShare doesn't work for giant MP3 libraries, but it works well for code trees.

Harvey
A: 

Cheater solutions that work:

  1. my preferred: simple e-mail, I just .zip a folder frequently and e-mail it to myself. If my computer dies, no problem because I also use "Leave mail on server" for POP3 accounts. Thus, I get backup and versioning together.

  2. use a Flash drive. Work from the flash drive and back up to your hard disk, or visa versa.

The above two methods work very well for a single developer using multiple computers.

Edit: oops, sorry, missed the team aspect. The e-mail solution still works but with a team source control is best because multiple people are mangling the same code. I find TFS and Visual Source Safe less than perfect solutions. The problem with source control systems is the learning curve to master them. Unfortunately, in a team environment, that's a necessary task.

gerryLowry
A: 

I love Microsoft Live Mesh, it's easy to use, you just select a folder to sync and you're good to go.

jkottnauer
+1  A: 

I think a lot of people are overcomplicating this. The solution is obvious. Just use a portable USB device and have your checkout directory there. For your given scenario, that would make a lot of sense.

Wim Hollebrandse
+1 here also: this is a very simple solution that seems like it is sufficient for what the OP needs. But if you choose not to commit your code, make sure you don't lose the USB drive!
Mark Byers
A: 

Use Fuse and sshfs to mount the relevant directories on your work machine on your machine at home.

Charles E. Grant
+1  A: 

Use git. You have all the version control system benefits, but working locally. If your project code is already in SVN, it's possible to use git-svn to make both git and svn collaborate. Here's an easy to follow guide on git-svn by example.

With git it's easy to branch so you'll want to branch very often. Git branches are different from SVN branches: they are stored locally and it's not simply a copy of your whole project like in SVN. Finally, Set up Dropbox in both computers so your changes are synched automatically.

So your workflow could be something like this:

  • git-svn clone http://mysvnrepo local_dir to get your local repository
  • git checkout -b my_new_branch when you want to work on a new feature
  • Check in your code as often as you need, without worrying about breaking other people's code
  • Local changes are kept in sync automatically thanks to Dropbox
  • When your code is ready, merge it to the master branch with git merge my_new_branch
  • And commit your changes back to the subversion repository, first update your local repository with git-svn rebase and then commit with git-svn dcommit
Cesar