- cvs -d cvs-myproj@cvs.foo.com:/cvs co projectwd
- mv projectwd myproj && cd myproj
- git-cvsimport -v -C ../git-myproj -a
- cd ../git-myproj && git status
For some reason, when I've done this, I ended up with all my files marked as deleted in my working copy... If you have the same problem, a simple git reset --hard will undo the deletion.
Now do some work, and commit in your git repo.
It is now time to export these commits in the CVS repo. You can review your commits with git log origin..master (This assumes that you worked in the master branch which is the case by default. The origin branch was created by cvsimport and should not be modified unless when you actually sync it with the CVS repo). Now go back to your CVS working copy:
- cd ../myproj
- cvs up -d
- for i in `GIT_DIR=../git-piscine-j01/.git git-cherry origin work | sed -n 's/^+ //p'`; do echo Exporting $i; GIT_DIR=../git-piscine-j01/.git git-cvsexportcommit -c -p -v $i || break; done
- cvs diff -u
- git-cvsimport -v -C ../git-myproj -a
- cd ../git-myproj
- git checkout origin
- git merge master
- git checkout master
At first I did not expect to have to do steps 7 and 8 but since the sha1 sums generated by the cvsimport for the commits exported by cvsexportcommit are different, these are required so that branches stay in sync. This extra merge step should however not be of a problem since it should be a simple "fast forward" merge. The only minor inconvenience is that commits made in git, exported to CVS and imported back to git will appear twice with different sha1 IDs.
This should be enough to work with git instead of CVS.
Thanks for the useful info - was very helpful.
ReplyDeleteYou state that to update the working copy with the latest cvs entries, to do:
ReplyDeletegit checkout origin
git merge master
Now I'm new to this, so I might be wrong, but it seems to me that it should be:
git checkout master
git merge origin
as "git merge X" takes the changes from X and applies them to the current branch, and in this case we want from cvs branch "origin" to working directory "master".
Here are two shell scripts I created. Thanks for the help!
- - - update-git.sh - - -
git-cvsimport -v -C ../git-project
cd ../git-project
git checkout master
git merge origin
- - - export-commits.sh - - -
for i in `GIT_DIR=../git-project/.git git-cherry origin master | sed -n 's/^+ //p'`; do echo Exporting $i; GIT_DIR=../git-project/.git git-cvsexportcommit -c -p -v $i || break; done