CVS stands for Concurrent Versions System, whereas GIT is, well, a version control system called GIT.
Migrating from CVS to GIT is not straightforward but it's not too troublesome either. This mentions an example of migrating a CVS repository to GIT, but there's too little information. My contribution here is a minimalist tutorial on the subject. In this tutorial, I assume you are the sole user of the repository (repo for short). GIT stores info about file mode (permissions), so it is recommended to use a filesystem that keeps this information (i.e., not FAT).
-
First create a directory, say ~/gittest (i.e. a directory called gittest in your home directory), then in gittest, do:
git cvsimport -v -a -i -k -d $CVSROOT ZBS
If you are familiar with CVS, you should know that $CVSROOT points to the CVS root repository. In this example, ZBS is the name of the project you are trying to import. To find out the meaning of the switches such as -v etc., type
git cvsimport --help
-
If you CVS repo is not corrupted, then the import would have been successful. Now, you need to clone the directory. Create the project directory ZBS and in the project directory do
git clone ~/gittest
Two steps so far and now you have a working GIT repo!
At the very least, you want to do the following:
-
To check the changes you have made on, say file "main.c", do
git diff main.c
To compare two commits (say with commit IDs 'da278fc15d6052d206aeae9f24ca3155f627d162' and '4f7b415465bea0927fc85d231b3358d98edfc946') of the file main.c, do
git diff da27..4f7b main.c
Note that it's sufficient to use the first few digits of the commit IDs as long as there is no other commit ID that starts with the same digits. Unlike CVS, GIT doesn't generate messy .#files in the directory. There are several variants of the diff command, be sure to check
git diff --help
You may want to tell GIT to use a GUI to display the differences. For me, my preference is FileMerge (command opendiff) on a Mac. This is what I do:
git config --global diff.external ~/git-opendiff.sh
This tells GIT to execute ~/git-opendiff.sh every time the diff command is executed. In the file ~/git-opendiff.sh, I have the following commands:
#!/bin/sh opendiff $2 $5
Caution: if you don't specify the file name with git diff, GIT will open FileMerge for every file that has been changed.
-
To see what files have been changed, or are untracked, do
git status
- To see the log of the file "main.c", do
git log main.c
To see only the log comment, do
git log --oneline main.c
However, git doesn't wrap log comments automatically, do
git shortlog -w80 main.c
to wrap log comments to 80 characters per line.
- To color-code the display, use the following commands:
git config --global color.diff auto git config --global color.status auto
Note that all issued config commands are stored in /.gitconfig.
- To check out an earlier version of main.c, say version abcd without making any changes to the history, do:
mv main.c main.bak
git checkout abcd main.c
To check out the last committed version, do:
git checkout HEAD main.c A word of warning for CVS users: the "checkout" command is not what you used to expect! For more info, see this.
That's it! This has got me started. To get the basic ideas about GIT, check out the excellent visual GIT tutorial (which doesn't tell you how to migrate CVS repo though, hence this tutorial). For general reference, read the Git Community Book. Alcides Fonseca has an intuitive diagram. |
|