Use GIT to help you dealing with CVS
A lot of people have to deal with CVS in their companies or in Open Source projects. Therefore they all know an annoying problem:
You are working on a huge change, introducing a complete new authentification mechanism. Therefore you have to touch a lot of classes. In the meantime, other developers have to change also some parts of the code you have to touch, because they have to fix bugs or introduce other features. You cannot commit your stuff into the CVS everyday until it’s finished as it would break the codebase and nodody would be able to compile the code anymore. So you just wait until you are finished. In that 7days of coding you don’t do any commit, but a lot of code was changed by others! So if you try to commit, you get a huge list of conflicts. It’s really a mess! Let’s drop that, and do it nice using GIT.
gc-import ext:foo@example.com:/repository myProj
cd myProj
Now, create your own branch. We will call it exp. In that branch you will introduce your new breaking-trough feature.
git checkout -b exp master
Let’s start coding your new authentification mechanism. Just use your standard workflow. Change, commit, change, commit. Meanwhile, track the changes from the repository by switching back into the master branch and run gc-update. Your personal branch than keeps up-to-date with the CVS head and you can adopt your feature to API changes made in the CVS head.
// edit …myfanynewauth
// commit
// edit
// commit
git checkout master
gc-update
git checkout exp
git merge master
After you finished introducing your new superb feature, just do a merge back from your personal branch (exp) back into the branch that tracks CVS by merging exp with master. You don’t have to do this step, You just can pick up your changes from exp directly and commit it if you want, because you are allready up-to-date with CVS due to your merge from master (see code above).
git checkout master
git merge exp
git log // pickup your changes
gc-commit -c a2334bc fe2346ab ….
GIT helps you to do things a little bit easier. You can commit, revert and diff every change during your developement and nobody recognize it, as it is just in GIT not in CVS.
Another exampleAssuming your CVS HEAD is broken, just import it into your git. Go back to the version that worked and then branch and work in your personal branch.
gc-import ext:foo@example.com:/repository myProj
Then checkout the version that worked
git log
// perfect, version a42bba seems to work
git checkout -b working a42bba
Start working on your branch. After you finished your work just merge it back into the master branch which tracks your CVS.
git checkout master
gc-update
git merge working
git-log
// search for your personal commits
gc-commit -c faab346 ab56dd2e ….