Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

version control - Migrate from CVS to Git without losing history

I need to know if there is a way to migrate my code from CVS source control to Git?

If yes, what about my history of commits?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is the process I used to migrate a SourceForge CVS repo to Git using cvs2git (latest stable release is here, but IIRC I used the github dev version), which works on both Windows and Linux without any compilation required since it's just Python.

Also, you don't need to own the repo with this method, you can for example migrate SourceForge projects that you don't own (you just need the right to checkout, so this works on any public repo).

How to import from sourceforge CVS to git.
First, you need to download/checkout the cvs repo with the whole history (not just checkout the HEAD/Trunk):

rsync -av rsync://PROJECT.cvs.sourceforge.net/cvsroot/PROJECT/* cvs

then use cvs2git (python script, works on all platforms, no compilation needed):

python cvs2git --blobfile="blob.dat" --dumpfile="dump.dat" --username="username_to_access_repo" --options=cvs2git.options --fallback-encoding utf-8 cvs

this should have generated two files blob and dump containing your whole cvs history. You can open them in a text editor to check that the content seems correct.

then initialize your git repo inside another folder:

mkdir gitexport/
cd gitexport
git init

then load up the exported cvs history onto git:

cat ../{blob,dump}.dat | git fast-import

and then place the git commit cursor at the end of history:

git reset --hard

finally and optionally, you can push to your remote git repository:

git push -u origin master

of course you need before to git remote add origin https://your_repo_url

Note: cvs2git.options is a JSON formatted configuration file for cvs2git where you can specify transforms for various things like author names (so that their nicknames will be automagically transformed to their full name after import). See the documentation here or the included example options file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...