In good old days, CVS used to be one of the most used SCM (source control management) tool. With the growing technology and the need of distributed systems, Git was born and with this CVS started rusting out. This is much of history for now. There are cases when we have a requirement to move our codebase from CVS to Git without losing commit histories. If we don’t In this blog, we are going to discuss the same.
- Need Python installed.
- Access to CVS server for getting the full code base.
- CVSNT server setup. (This is not required if you are already on CVS server. CVS client doesn’t work)
- Need Git installed.
Steps to convert CVS to Git
Install Python 2.7.x
Download and install Python 2.7.x and set it to OS environment path.
Install CVSNT server. (Not required when you are already on CVS Server)
Download and install CVSNT server version. You will need it only once and then you can uninstall it. https://www.march-hare.com/cvspro/
Download the cvs2git tool and extract it to a new folder ‘temp’.
cvs2git comes prepackaged with cvs2svn tool. You can download it from the following location.
Go to CVS server and create a zip of the full code base.
Find out the CVSRoot and zip the parent folder.
Extract the zipped codebase to the folder ‘temp’.
Open the command prompt and navigate to the following directory, replace the version with the correct version.
Run the following command from the command prompt.
python.exe cvs2git –blobfile=git-blob.dat –dumpfile=git-dump.dat –use-external-blob-generator –username=cvs2git C:/temp/<Extracted CVSFolder>
Once this command has completed successfully it will create two files, git-blob.dat and git-dump.dat. This command will fail if you have CVS client version installed.
Initialize an empty bare repository in temp folder.
git init –bare <YourProrjectName>.git
Navigate to <YourProrjectName>.git
Import dat files in repository.
git fast-import –export-marks=../../cvs2svn-2.5.0/git-marks.dat <../../cvs2svn-2.5.0/git-blob.dat
git fast-import –import-marks=../../cvs2svn-2.5.0/git-marks.dat <../../cvs2svn-2.5.0/git-dump.dat
By now your local Git project is ready.
Call garbage collector. (Optional)
git gc –prune=now
You can verify source history using the below command.
It opens up the git history browser.
Here onwards, the steps are for pushing the codebase to a common remote Git server.
Clone your bare repository in ‘temp’.
Navigate to temp and run this following command. The following command will create the folder named <YourProrjectName>.
git clone <YourProrjectName>.git
Navigate to <YourProrjectName> and add remote location.
Remote location will be you common git server location which will be shared by your team.
git remote add origin remote repository URL
Push your local git to the remote.
git push origin master
Now you can delete your bare repository ‘temp/<YourProrjectName>.git’
That’s all about CVS to git codebase migration. Next topic we are going to update the ant build script and configure it will git setup.