GitCVS

De Pontão Nós Digitais
Revisão de 13h37min de 20 de julho de 2012 por V1z (discussão | contribs)
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
Ir para navegaçãoIr para pesquisar

See also Git, GitSvn.

Background and Motivation

Many groups have local CVS repositories with their private code, and haven't yet migrated to Subversion or a newer version control system. This guide describes how to use Git to import the code from these repositories and to commit changes back to them, so that you can get the benefits of Git (local history, local commits, branching workflow, independence of the server).

For more detailed background material and other information on Git and VXL, see the wiki page GitSvn.

CVS import into a local Git repository

In my group I copied my-lab-vxlsrc (this is a directory with the name of the CVS module of interest) and the CVSROOT dir from /path/to/cvsroot to my local disk. I placed them in a directory, let's call it my-lab-cvsroot.

Create a dir, say, my-lab-git, chdir in there, and do:


 $ git cvsimport -d /path/to/my-lab-cvsroot -r cvs -k -v my-lab-vxlsrc

This takes about 40min.

Basic configs from inside the newly created git repository

 git config cvsimport.module lemsvxlsrc
 git config cvsimport.r cvs
 git config cvsimport.d :ext:server.yourlab.edu:/path/to/cvsroot


Test updating from cvs, now remotely

 # MAKE SURE YOU'RE IN THE ROOT DIRECTORY OF YOUR GIT REPOSITORY AND IN MASTER
 $ git cvsimport
 # MAKE SURE YOU'RE IN THE ROOT DIRECTORY OF YOUR GIT REPOSITORY AND IN MASTER

This takes 1min from East coast to West coast and it fetched changes committed in the interim very well.


Exporting Changes to CVS

Work on a topic branch and create a merge commit on an up-to-date master and export that single merge commit to CVS. This won't work if your merge was a fast-forward, so you have to use the --no-ff option when performing the merge.

 $ git config cvsexportcommit.cvsdir /path/to/cvs/checkout
 # on master
 $ git merge --no-ff --log -m "Optional commit message here" topic/branch/name
 $ git cvsexportcommit -u -p -c ORIG_HEAD HEAD

Shortcomings

You need to keep a CVS checkout around. Also, you tend not to commit code remotely since it is so easy to commit to your local repository, and relatively painful to merge and cvsexportcommit every time. Backups are crucial here.

References

* Stack Overflow Article
* Complementary Information

Questions

If you have any questions, feel free to contact Ricardo Fabbri (ricardofabbri at users.sf.net) or the vxl-users list.