开发者

Most robust way to convert a CVS repository containing Eclipse projects to git?

I have a situation where I have an elderly CVS repository which we would like to convert to git once and for all while keeping full history etc.

All folders at the root of the repository contains Eclipse projects (either plain or dynamic web projects) including .classpath and .project. We use Team ProjectSets to check out the projects we need for a given task (where the project set is located in the project containing the main, and the rest are library projects).

When the Team ProjectSet is checked out, the workspace is fully populated.

This approach has worked pretty well for many years (except the project set part which came with 3.5), and we would like to work in a similar way with git if possible, but we are uncertain how.

I've played somewhat with git cvs import but it faile开发者_如何学编程d - probably due to us not using modules.

How would you suggest we do this, and how should we work with git to allow our current usage of shared library projects? Would we HAVE to introduce maven and create maven modules for our library projects? Or just ant ivy?


EDIT: I've now managed to convert our CVS repository to Subversion with a suitable cvs2svn invocation and found that Eclipse recognizes the resulting Subversion repository nicely. Unfortunately after cloning http://github.com/iteman/svn2git` and trying to run bin/svn2git I get

tra@Sandbox:~/cvsgit/svn2git/svn2git$ bin/svn2git
bin/svn2git:35:in `initialize': wrong number of arguments (2 for 1) (ArgumentError)
        from bin/svn2git:35:in `new'
        from bin/svn2git:35

This is with Ubuntu 10.04.1 LTS Server and I've tried various sudo things with Ruby and its gems without fully understanding what I did as I am not a Ruby programmer so I may have messed up things a bit. I'd appreciate advice - if the easiest is to install another Linux variant to do the conversion, that is fine.


EDIT:

https://help.ubuntu.com/community/Git http://css.dzone.com/articles/subversion-git-morning


Edit: My first try with the default svn2git completed successfully (after a while), and I get a nice repository where git branch -a reports roughly

tra@Sandbox:~/gitroot/svnroot$ git branch -a
* master
  remotes/XX64_DEPLOYED_CODE
  remotes/Beta1
  remotes/Beta2
  remotes/SV46
  ... lots more

We are interested in being able to check out the SV46 branch and work with it (we basically do not care about the tags, just actual branches). I have set up gitosis and pushed this repository to gitosis, and cloned it to another computer to find out how to do the "work with SV46" bit with Eclipse. THAT repository does not know of all the branches:

tra@TRA ~/git/git00 (master)
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

Do I need to massage the original result from svn2git to get the information into the gitosis repository? Do I need to clone with an argument? Should I redo the svn2git step with the suggested version instead of the one shipping with Ubuntu?

EDIT: It turned out that publishing the svn2git generated repository with "git push --mirror" made things shown up in the gitosis repository. I now see the following inside gitosis (trimmed):

tra@Sandbox:/srv/gitosis/repositories/git01.git$ git branch -a
* master
  remotes/XX64_DEPLOYED_CODE
  remotes/Basic_Beta1
  remotes/Beta1
  remotes/Beta2
  remotes/SV46
  ... lots more
tra@Sandbox:/srv/gitosis/repositories/git01.git$ git branch
* master
tra@Sandbox:/srv/gitosis/repositories/git01.git$ git tag -l
tra@Sandbox:/srv/gitosis/repositories/git01.git$

Trying to clone this repository with git clone gitosis@sandbox:git01 -b remotes/SV46 or git clone gitosis@sandbox:git01 -b SV46 both tell me that the remote branch is not found upstream origin, using HEAD instead.

Am I barking up the wrong tree?


First of all, using submodules for independent parts of your Central VCS repository (i.e. your CVS repo) is always good (see "What are the Git limits?").
That mean you will end up with many independent Git repo, that is "set of files evolving independently one from another", which is why submodules exist.

So multiple Git import (in multiple repo) are required.

But since git cvs import is not always up to the task, I would recommend:

  • cvs2svn in order to get an SVN repo first (just one repo)
  • svn2git in order to properly convert your SVN repo to a git one (i.e. transforming SVN branches into Git branch and SVN tags into Git tags)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜