简体   繁体   English

从svn迁移到git

[英]migrate to git from svn

I want to migrate from svn server to git and completely move to git. 我想从svn服务器迁移到git,然后完全迁移到git。

My svn repository contain several folder each one contain difference project. 我的svn存储库包含几个文件夹,每个文件夹包含一个不同的项目。

I cloned the svn repository to git using git svn then i tried to split each of the folders to difference branch using this command: git subtree split -P name-of-folder -b name-of-new-branch. 我使用git svn将svn存储库克隆到git,然后尝试使用以下命令将每个文件夹拆分为差异分支:git subtree split -P name-of-folder -b name-of-new-branch。

The problem is that in some part of the history I mvoed one of the folder to other location and the history in the git repository is keeped only from this position. 问题是,在历史记录的某些部分中,我将其中一个文件夹移动到了其他位置,而git存储库中的历史记录仅保留在该位置。

I can not see the history even immediately after I run git svn clone 我什至在运行git svn clone之后也看不到历史记录

My svn layout is like this: 我的svn布局是这样的:

svnrepo/
  folderA/
      projectA files(.sln,.cpp)
  folderB/
      projectB files(.java)
  folder/
      folderC/
          folderC files(.cs)
      folderD/
          folderD files(.cs)

I want that will be branch for folder A branch for folderB branch for folderC and branch for folderD. 我希望该文件夹是文件夹A的分支,文件夹B的分支,文件夹C的分支,文件夹D的分支。

edit: In some point of my project I moved folderC and folderD like this: 编辑:在我的项目中,我像这样移动folderC和folderD:

folder/
       web/
          folderC/
              folderC files(.cs)
          folderD/
              folderD files(.cs)

Then when I try to clone from the url of folderC I get the history only from the point I moved folderC to web although there was a lot of history before. 然后,当我尝试从folderC的URL进行克隆时,尽管以前有很多历史记录,但我仅从将folderC移至Web的那一点获得历史记录。

Is there any way to save also the history from the previous location? 有什么办法可以保存以前位置的历史记录吗?

git-svn already has options to deal with SVN branches and tags, but they're documented in init not clone . git-svn已经具有处理SVN分支和标签的选项,但是它们在init记录,而不是clone git svn clone is basically git svn init plus git svn fetch and takes their options. git svn clone基本上是git svn init加上git svn fetch并采用它们的选项。

For a typical SVN layout... 对于典型的SVN布局...

svnrepo/
    trunk/
    branches/
        branch1/
        branch2/
    tags/
        tag1/
        tag2/

You can tell git-svn your layout with --trunk , --tags and --branches . 你可以告诉混帐svn的与您的布局--trunk--tags--branches git svn clone --trunk=trunk/ --tags=tags/ --branches=branches/ <svnurl> . git svn clone --trunk=trunk/ --tags=tags/ --branches=branches/ <svnurl> There's a shortcut for this standard layout, --stdlayout . 此标准布局有一个快捷方式--stdlayout

For the OP's non-standard layout... 对于OP的非标准布局...

svnrepo/
  folderA/
      projectA files(.sln,.cpp)
  folderB/
      projectB files(.java)
  folder/
      folderC/
          folderC files(.cs)
      folderD/
          folderD files(.cs)

It would be git svn --branch=folderA --branch=folderB --branch=folder/folderC --branch=folder/folderD . 这将是git svn --branch=folderA --branch=folderB --branch=folder/folderC --branch=folder/folderD But from the OP's description, these sound more like separate projects, not branches of a single project. 但是从OP的描述来看,这些听起来更像是单独的项目,而不是单个项目的分支。 They should be separate Git repositories. 它们应该是单独的Git存储库。

SVN repositories are expensive to setup and maintain, so SVN encourages you to shove unrelated projects into one repository. SVN信息库的设置和维护成本很高,因此SVN鼓励您将无关的项目推送到一个信息库中。 Git repositories are super cheap, Git works best when each project is its own repository. Git存储库非常便宜,当每个项目都是自己的存储库时,Git效果最佳。 So when you convert, it's best to split each project into its own Git repository. 因此,当您进行转换时,最好将每个项目拆分到自己的Git存储库中。 Then later you can stitch related projects together with git subtree if you find you need it. 后来 ,你可以缝合相关的项目连同git subtree ,如果你发现你需要它。

For an SVN repository with multiple projects that you want to turn into multiple Git repositories, simply run git svn clone multiple times on each SVN directory, just as you would check them out from SVN. 对于要转换为多个Git存储库的包含多个项目的SVN存储库,只需在每个SVN目录上多次运行git svn clone ,就像从SVN中检出它们一样。

git svn clone https://svn.example.com/folderA/
git svn clone https://svn.example.com/folderB/
git svn clone https://svn.example.com/folder/folderC/
git svn clone https://svn.example.com/folder/folderD/

Pro Git has a chapter on converting from SVN to Git that will help more. Pro Git有一章介绍了如何从SVN转换为Git,这将提供更多帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM