Saturday, October 3, 2009

Dropbox and GIT

This semester (fall 09), I have attended a project-based course at IU, Bloomington. It's a network class. First project is to use libpcap to read packets from capture file (.pcap) and analyze each packet (e.g. IP, TCP, UDP, header size, flag, checksum). Everything in the project went fine, until I want to find some personal version control to use with it. Assembla used to provide private repository for free, but now they change their policy. So, I looked around and found Unfuddle, it provided 100MB private project with unlimited repositories. However, it allows only 2 people in project for free edition. It should be work for me because I would use it alone, still it didn't satisfy my need. Finally, I came across Dropbox, which gives you 2GB of space and the ability to share folder with your friends.

I first used Dropbox about 1 years ago when I was at home. I wasn't impressed with it because it seems to be very slow in Thailand. Now, I'm in U.S., I have to say it a lot faster. Although I get used to using SVN, my solution is to use it with Git repository because it's distributed version control instead of centralization. Dropbox has already provided version control you can revert or undelete your files, but Git will provide more flexibility for programmers.

The way to do it is simple, I just install git and Dropbox on all my machines (Laptop and department's machines). Then create Git repository folder you want to share via

$git init

and add all files in folder or files you want through

$git add .

After you install Dropbox, it will become like a folder on that computer. Thus, I just clone Git repository to Dropbox's folder. For example, if my Git repository is at ~/ptangcha/network my command would be

$git clone ~/ptangcha/network ~/Dropbox/network

Done! I have Git repository in my Dropbox. Now, if I want to get my code in other machines, I just clone Git repository from Dropbox to folder on machines.

Since my code will be run on Linux machine (no libpcap on windows :( ), I don't want to to convert LF (Line feed) to CRLF (newline for windows) every time I add new file. Git converts it to CRLF because it detect that my repository is on Windows. So, I just configure git with this code.

$git config core.autocrlf false

I'm still newbie to Git. There are many useful command and many things to play with before I can fully benefit from it.


Resources:
- http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html