from the CVS to GitHib

Lately, I’ve been thinking about the many complexities of being in the software industry, specifically designing for the web. Of course, in the past, I’ve talked about how little colleges prepares one for the “real world” — and that’s a different story.

If I haven’t lost you yet, I faced a recent challenge in converting a CVS codebase to a more modern Git. Perhaps, you’re not sure what CVS or Git is, welcome aboard.

In the world of software development, you end up making a file, or two, and a bunch of more files, eventually, you make changes, you hate you changes, you want to go back to a bunch of changes. Or maybe even more complex still, you’re working with your friend on some folder with some files inside — how do you know your friend will not overwrite your work. That is the problem that software like Git or CVS help to solve, almost the same way that Microsoft Word helps write a better essay but I’m sure you’re not reading this to learn about Git or CVS… let’s get down to business.

It turns out that CVS is slow and not as versatile as Git, the challenge was convert 3 years worth of commits and changes to the newer Git and have it take advantage of the Awesome GitHub, let’s get started.

1. You will obviously need the CVS repo you will be converting
and you will need file-level access. It took me a while to understand this since I never used CVS, basically, you will need to be physically in the folder that has “CVSROOT” in it. Hopefully, you can login to the server, and the rest is cake from here.

2. I’m assuming you’re on Windows system:
a. Download Cygwin, follow this guide to get setup (be sure to install the ‘git’, ‘svn’, and ‘python’ packages, you need them to run the scripts that does the conversions).
b. Open up Cygwin, hopefully you’ve gone through the previous pages, and now let’s move on into the command world.

3. a. Let’s download cvs2svn
[cc lang=”bash” width=”680px”]svn co –username=guest –password=”” cvs2svn-trunk [/cc]
b. Navigate to the folder:
[cc lang=”bash” width=”680px”] cd cvs2svn-trunk[/cc]
c. Run the program that does the conversion:
[cc lang=”bash” width=”680px”]
cvs2git \
–blobfile=cvs2svn-tmp/git-blob.dat \
–dumpfile=cvs2svn-tmp/git-dump.dat \
–username=cvs2git \
Some notes, on this mysterious looking things: this is just generating a dump that can be imported into Git as we will do soon; hopefully, everything goes well and you have those files (“git-dump.dat” and “git-blob.dat” generated)

4. Convert to git:
a. Create an empty git directory:
[cc lang=”bash” width=”680px”]
mkdir some_project.git
b. Navigate into the directory and “git” it
[cc lang=”bash” width=”680px”]
cd some_project.git
git init –bare
c. Now import that dump we created
[cc lang=”bash” width=”680px”]
cat ../cvs2svn-tmp/git-blob.dat ../cvs2svn-tmp/git-dump.dat | git fast-import
5. Start using you files — no, we are almost done, the file we created previously where not actually files yet, just “things” git understands, and how it store the content of the files, now let’s generate files we can use:
a. Navigate to the directory you want it in, here we go “HOME”
[cc lang=”bash” width=”680px”]cd $HOME[/cc]
b. Create the project files
[cc lang=”bash” width=”680px”]git clone /path/to/some_project.git
c. Now go into your folder:
[cc lang=”bash” width=”680px”]cd some_project
(yes, without the .git)

We are all set, hack away. Oh, and there is the wonderful GitHub.

Leave a Reply