简体   繁体   中英

migrate to git from svn

I want to migrate from svn server to git and completely move to git.

My svn repository contain several folder each one contain difference project.

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.

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.

I can not see the history even immediately after I run git svn clone

My svn layout is like this:

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.

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.

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 clone is basically git svn init plus git svn fetch and takes their options.

For a typical SVN layout...

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

You can tell git-svn your layout with --trunk , --tags and --branches . git svn clone --trunk=trunk/ --tags=tags/ --branches=branches/ <svnurl> . There's a shortcut for this standard layout, --stdlayout .

For the OP's non-standard layout...

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 . But from the OP's description, these sound more like separate projects, not branches of a single project. They should be separate Git repositories.

SVN repositories are expensive to setup and maintain, so SVN encourages you to shove unrelated projects into one repository. Git repositories are super cheap, Git works best when each project is its own repository. So when you convert, it's best to split each project into its own Git repository. Then later you can stitch related projects together with git subtree if you find you need it.

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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