tags:

views:

149

answers:

5

If, for security reasons, source code can only be stored on my home computer and office computer, which source control would be best IF the only method of transporting the code would be a USB key?

SVN or GIT?

note: there is no network connection between the 2 computers.

+5  A: 

Either one would work. If you were using SVN you could just do your work off of the USB key. With Git, you have the possibility of cloning the repo off the the key and just pushing to the key when you're ready to move your data to the office.

dj2
+7  A: 

I recommend git.

Either way you're going to want the canonical repository on the USB key. In git you might do this:

Make a "bare" repo on the USB key:

$ mkdir /path/to/usbkey/myapp.git
$ cd /path/to/usbkey/myapp.git/
$ git init --bare
Initialized empty Git repository in /path/to/usbkey/myapp.git/

Bare repository directories are usually named "something.git" - you can name them whatever you want, but the ".git" convention is very widely used.

Now you can clone the repo:

$ cd /my/source/dir/
$ git clone /path/to/usbkey/myapp.git
Initialized empty Git repository in /my/source/dir/myapp/.git/
warning: You appear to have cloned an empty repository.

It will warn you that the repo is empty. Let's put something in it:

$ cd myapp
$ echo "some stuff." > README
$ git add README
$ git commit -m 'added a README'
[master (root-commit) 155b8ea] added a README
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 README

And then push it to the USB key:

$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 231 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /path/to/usbkey/myapp.git
 * [new branch]      master -> master

When you get to your other computer, just clone the repo from your USB key again. You'll have to make sure you remember to push your changes, but you know you'll always have a backup because you'll have three full copies of the repo whenever you're synced up.

An alternate way to do it with git is to only have one repo - the one on the USB key. You wouldn't ever have to remember to push to it, but your code would only be on the key unless you used some other explicit backup system. That would be bad.

If you were to use SVN on the USB key you would still have to remember to commit and pull your changes in the same way has having a bare git repo, but you wouldn't get the free automatic backups that doing so with git gives you. Also you would miss out on all the other niceties of git, but that's a whole other discussion. See Why Git is Better Than X.

Neall
This is almost exactly what I do. I have a repo set up on my systems (home and work) called `homework` that targets my USB key, so all I have to do is push and pull to/from homework as needed. Any commits to the main repo at work pass through my working copy on my computer. So a pull from homework followed by a push to origin updates the main repo.
daotoad
+4  A: 

With Git, in addition to having bare git repository on USB for transfer (as in Neall and dj2 answers), you can also use "git bundle" command for off-line transfer.

Jakub Narębski
A: 

Easy, GIT or some other DVCS - not because DVCS is inherently better than, say, subverion but because a DVCS is a better match to your requirements in the way it allows you to work.

In the abscence of a network connection you're not going to be able to run/access SVN from your "server" repository and that kind of defeats the purpose whereas with DVCS you can use a cloned repository on your USB key as a bridge between the two dev environments.

Murph
A: 

As Dj2 said, both can work, but Git is clearly the best choice, for that purpose. I found anyway a bit strange to base a so crucial choice on a "side-feature" like this one...

didoux