43

For my school work, I do a lot of switching computers (from labs to my laptop to the library). I'd kind of like to put this code under some kind of version control. Of course the problem is that I can't always install additional software on the computers I use. Is there any kind of version control system that I can keep on a thumb drive? I have a 2GB drive to put this on, but I can get a bigger one if necessary.

The projects I'm doing aren't especially big FYI.

EDIT: This needs to work under windows.

EDIT II: Bazaar ended up being what I chose. It's even better if you go with TortoiseBzr.

tzot
  • 92,761
  • 29
  • 141
  • 204
Jason Baker
  • 192,085
  • 135
  • 376
  • 510

14 Answers14

21

I do this with Git. Simply, create a Git repository of your directory:

git-init
git add .
git commit -m "Done"

Insert the stick, cd to directory on it (I have a big ext2 file I mount with -o loop), and do:

git-clone --bare /path/to/my/dir

Then, I take the stick to other computer (home, etc.). I can work directly on stick, or clone once again. Go to some dir on the hard disk and:

git-clone /path/to/stick/repos

When I'm done with changes, I do 'git push' back to stick, and when I'm back at work, I 'git push' once again to move the changes from stick to work computer. Once you set this up, you can use 'git pull' to fetch the changes only (you don't need to clone anymore, just the first time) and 'git push' to push the changes the other way.

The beauty of this is that you can see all the changes with 'git log' and even keep some unrelated work in sync when it changes at both places in the meantime.

If you don't like the command line, you can use graphical tools like gitk and git-gui.

Milan Babuškov
  • 59,775
  • 49
  • 126
  • 179
  • I'm using Windows unfortunately. I put that in the tags, but I suppose I should have also put it in the question. – Jason Baker Sep 18 '08 at 23:17
  • 7
    Git works on Windows quite good, even graphical tools like Git-GUI and Gitk work as good as on Linux. I recommend using msysgit port from http://code.google.com/p/msysgit/ – Milan Babuškov Feb 17 '09 at 18:25
  • Thanks Milan for giving brief yet meaningful steps. – Amit Vaghela Oct 28 '10 at 06:04
  • 1
    +1. Concise. I was looking for a confirmation of the steps to setup a repository on a USB drive :) – user Jun 07 '11 at 14:11
  • 1
    On the download page there is the portable version: http://code.google.com/p/msysgit/downloads/list Currently the latest version says "beta" but it is very stable. I am using it a lot with no issues. Can absolutely recommend it. – mit Aug 12 '11 at 02:35
18

Darcs is great for this purpose.

  • I can't vouch for other platforms, but on Windows it's just a single executable file which you could keep on the drive.
  • Most importantly, its interactive command line interface is fantastic and very quickly becomes intuitive (I now really miss interactive commits in any VCS which lacks them) - you don't need to memorise many commands as part of your normal workflow either. This is the main reason I use it over git for personal projects.

Setting up:

darcs init
darcs add -r *
darcs record -am "Initial commit"

Creating a repository on your lab machine:

darcs get E:\path\to\repos

Checking what you've changed:

darcs whatsnew      # Show all changed hunks of code
darcs whatsnew -ls  # List all modified & new files

Interactively creating a new patch from your changes:

darcs record

Interactively pushing patches to the repository on the drive:

darcs push

It's known to be slow for large projects, but I've never had any performance issues with the small to medium personal projects I've used it on.

Since there's no installation required you could even leave out the drive and just grab the darcs binary from the web - if I've forgotten my drive, I pull a copy of the repository I want to work on from the mirror I keep on my webspace, then create and email patches to myself as files:

darcs get http://example.com/repos/forum/
# Make changes and record patches
darcs send -o C:\changes.patch
Jonny Buchanan
  • 61,926
  • 17
  • 143
  • 150
13

You could use Portable Python and Bazaar (Bazaar is a Python app). I like to use Bazaar for my own personal projects because of its extreme simplicity. Plus, it can be portable because Python can be portable. You will just need to install it's dependencies in your Portable Python installation as well.

Martin W
  • 1,359
  • 7
  • 12
10

The best answer for you is some sort of DVCS (popular ones being Git, Mercurial, Darcs, Bazaar...). The reason is that you have a full copy of the whole repository on any machine you are using. I haven't used these systems personally, so others will be best at recommending a DVCS with a small footprint and good cross platform compatibility.

Justin Standard
  • 21,347
  • 22
  • 80
  • 89
8

I'd use git. Git repos are really small and don't require a daemon. You can probably install cygwin or msysgit on your flashdrive.

Edit: here are some instructions for installing cygwin on a flash drive

Aaron Jensen
  • 6,030
  • 1
  • 30
  • 40
  • 1
    git on windows is to much of a hassle in comparison with Mercurial or Bazaar. I use git when on Linux and Mercurial when on windows. – Valentin V Apr 27 '09 at 06:50
  • 1
    @Valentin: I would disagree. Git works just fine on Windows without any installation (i.e. from USB drive). Also note that msys Git recently started to include "PortableGit" build on their Google Code site (http://code.google.com/p/msysgit/). – Milan Gardian May 01 '09 at 13:44
5

Just to add an extra resource Subversion on a Stick. I've just set this up on my 4GB USB Drive, pretty simple and painless.

Thought I am now very tempted to try Bazaar.

Update: I've setup PortablePython on my USB drive, simple, but getting bazaar on there ... I gave up, one dependency after another, and as I've got svn working.
If anyone knows of an easy portable installer, I'd be greatful.

thing2k
  • 608
  • 1
  • 7
  • 16
4

I recommend Fossil http://www.fossil-scm.org/

includes

  • command line
  • dvcs
  • cross platform (and easy to compile)
  • 'autosync' command make the essential task of syncing to a backup easy.
  • backup server configuration is a doddle.
  • easy to learn/use
  • very helpful community
  • web ui with wiki and bugtracker included.
  • 3.5Mb, single executable
  • one sqlite database as the repository
user1461607
  • 2,416
  • 1
  • 25
  • 23
Stephen
  • 1,215
  • 2
  • 25
  • 40
3

You could put the subversion binaries on there - they're only 16ish megs, so you'll have plenty of room for some repositories too. You can use the official binaries from the command line, or point a graphical tool (like TortoiseSVN) to the repository directory. If you're feeling fancy then you could rig the drive to autorun the SVNSERVE application, making any computer into a lightweight subversion server the minute you plug in the drive.

I found some instructions for this process here.

The Digital Gabeg
  • 2,765
  • 3
  • 21
  • 16
3

I use subversion on my thumb drive, the official binaries will work right off the drive. The problem with this trick is you need to access a command line for this to work or be able to run batch files. Of course, I sync the files on my thumb drive to a server that I pay for. You could always host the repository on a desktop (use the file:/// protocol) if you don't want to get hosting space on the web.

epochwolf
  • 12,340
  • 15
  • 59
  • 70
  • While the tortise intergration wouldn't work without being installed. You may be able to use soem of the UIs off of a thumbdrive. Havn't tried this myself but it may be easier then SVN command lines. – Matthew Whited Jan 08 '10 at 20:33
3

I will get lynched for saying this answer, but it works under Windows: RCS.

You simply make an RCS directory in each of the directories with your code. When time comes to check things in, ci -u $FILE. (Binary files also require you to run rcs -i -kb $FILE before the first checkin.)

Inside the RCS directory are a bunch of ,v files, which are compatible with CVS, should you wish to "upgrade" to that one day (and from there to any of the other VCS systems other posters mentioned). :-)

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
1

I'm using GIT according to Milan Babuškov's answer:

(1) create repository and commit (on office PC)

mkdir /home/yoda/project && cd /home/yoda/project

git init

git add .

git commit -m "Done"

(2) insert USB stick and make a clone of the repository

cat /proc/partitions

mount -t ext3 /dev/sdc1 /mnt/usb

git clone --bare /home/yoda/project /mnt/usb/project

(3) take the USB stick home and make a clone of repository at home

cat /proc/partitions

mount -t ext3 /dev/sdc1 /mnt/usb

git clone /mnt/usb/project /home/yoda/project

(4) push commits from home PC back to USB stick

mount -t ext3 /dev/sdc1 /mnt/usb

cd /home/yoda/project

git push

(5) take USB stick to the office and push commits from stick to office PC

mount -t ext3 /dev/sdc1 /mnt/usb

cd /mnt/usb/project

git push

(6) pull commits from office PC to USB stick

mount -t ext3 /dev/sdc1 /mnt/usb

cd /mnt/usb/project

git pull

(7) pull commits from USB stick to home PC

mount -t ext3 /dev/sdc1 /mnt/usb

cd /home/yoda/project

git pull

yoda
  • 4,859
  • 3
  • 19
  • 9
1

Flash memory and version control doesn't seem like a good idea to my ears. I'm afraid that the memory will wear out pretty soon, especially if you take extensive use of various version control operations that make many small disk operations (merge, reverting to and fro, etc).

At the very least, make sure that you back up the repository as often as humanly possible, in case the drive would fail.

Henrik Paul
  • 66,919
  • 31
  • 85
  • 96
  • You would think so. However since version control happens on human scale (I don't check in many times a second), this isn't an issue in practice. – Brian Carlton Feb 24 '09 at 21:43
  • I wasn't referring to the performance, but the lifetime and quality of some poor Flash memory. – Henrik Paul Feb 25 '09 at 08:15
  • This isn't 1985. Newer flash drivers will move data around to get more cycles per macro cell. Also each cell typically has more then 10k cycles. I don't think a simple repository for homework causing that much of a problem. – Matthew Whited Jan 08 '10 at 20:36
  • I thought it was more like 100k write operations, but if we stick with the 10k, then if you do the above process twice a day, i.e. 2xpull and 2xpush, then you get almost seven years use out of a $5 stick. – CyberFonic Feb 08 '10 at 07:49
  • I think H.P.'s warning has value. But version control can be considered scalable. If you have a small-scale app, and use common sense for back-ups as advised, a flash drive sounds great to me. – Smandoli Aug 12 '10 at 13:53
1

Subversion would kinda work. See thread

Personally, I prefer to keep everything on a single machine and Remote Desktop into it.

ykaganovich
  • 14,736
  • 8
  • 59
  • 96
0

bitnami stack subversion it's easy to install. You can try to install so too xampp with portableapps.com and subversion.