I'm starting my professional career in programming and needs help ! What is the simplest way to migrate from CVS to Git .
2 Answers
The simplest way is to take the current state of your project and commit it to a new Git repository. You will loose all the history of the project, but that is the simplest way and for that you asked.
If you want to know the most sophisticated (best) way, then first transform your CVS repository to a CVS repository with cvs2svn
and then transform the result git, with svn2git
(do not use git-svn
for a one-time conversion, it is not the right tool for that purpose). There are many tools with this name. Probably the best is the KDE one at https://github.com/svn-all-fast-export/svn2git. To analyze the SVN repo history upfront for building up proper rules for svn2git, you might use svneverever from here: http://blog.hartwork.org/?p=763

- 35,631
- 4
- 76
- 102
-
The first paragraph does not answer the question. The question is not "how do I get code hosted in CVS to Git", but rather migrating CVS to Git, which obviously means that the history should be preserved. – Joseph K. Strauss May 04 '16 at 18:38
-
That's a matter of definition. Some people consider history superfluous and would be fine with that method. Not me, but some. So then take the second paragraph. – Vampire May 04 '16 at 19:14
I have used cvsimport sucessfully many times.
I have found that it does not work (on Windows) from the Git BAsh, but works well from cygwin.
I use the following options (obviously replace usernames, servers, and file locations):
export CVS_RSH=ssh
git cvsimport -v -d myname@myserver:/path-to-cvsroot -C /cygdrive/c/git-repo -z 300 -R -p -q,-b,HEAD MYCVSPROJ
You can look at the documentation for git-cvsimport and cvsps to see what those options do.
This option can also work incrementally, so if some users are still using CVS, you can still start the import process, and then re-import later.
The imports are to the origin branch (not to be confused with a remote).
The commits will have the username from CVS as the user.name and user.email. Another problem, is that the times are all in GMT. This can be remedied with the following:
git filter-branch -f --env-filter 'export GIT_AUTHOR_EMAIL=${GIT_AUTHOR_NAME}@mycompany.com; export GIT_COMMITTER_EMAIL=${GIT_COMMITTER_NAME}@mycompany.com; export GIT_COMMITTER_DATE=$(echo ${GIT_COMMITTER_DATE} | perl -pe "s/ \+0000//"); export GIT_AUTHOR_DATE=$(echo ${GIT_AUTHOR_DATE} | perl -pe "s/ \+0000//");' --tag-name-filter cat -- --all
Another issue, is that all files will be executable, something that is probably not wanted. To fix this use this version of BFG Repo Cleaner which will make all files non-executable.
Please see the documentation of all tools/commands for more information.

- 4,683
- 1
- 23
- 40