Migrating from Subversion to Git where repository was not initially using standard layout

I am try to migrate a Subversion repository which was not initially using the standard layout. I cannot figure out how to migrate it.

For Example. In SVN Rev 1. – 700, the layout is

[svn]/projectfile
[svn]/projectfile2

Until the revision 700 then it change to

[svn]/trunk/projectfile
[svn]/tags
[svn]/branches

How can I run the git svn init command?

Right now when I use

git svn init -s <subversion_repository>

it will show everything in the directory like there are no branches. (same like use below command)

svn checkout <subversion_repository_root>/

  • Git push synchronization between team members
  • How to set up a heterogeneous multiuser git/svn environment
  • Dropping older Git commits from history?
  • Why git svn cannot clone a bare repo?
  • How can I make git-svn get rid of remote branches that don't exist anymore?
  • Oddly formatted SVN repo to Git
  • git-svn and local branches
  • How do I continue pulling from subversion from a git clone which was not originally pointing to svn
  • 2 Solutions collect form web for “Migrating from Subversion to Git where repository was not initially using standard layout”

    As I don’t have a subversion repo at hand to try this out with, I can only outline a way of solving this which may or may not work:

    • First, make a directory to hold your Git repo and cd into it
    • Initialize your Git repo: git svn init svn://path/to/svn/repo
    • Inside this repo, run git svn fetch --revision 1:699 (Or whatever the revision range is where you used the non-standard layout)
    • Modify .git/config and modify the [svn-remote] section to add/modify the fetch, branches and tags entries:
      [svn-remote "svn"]
        url = svn://path/to/svn/repo
        fetch = trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*
    
    • Run git svn fetch --revision 700:HEAD to fetch the rest of the repo
    • If everything worked until this point, but you don’t have any files in your working directory, run git svn rebase --local to make sure Git creates the files.

    In theory, this should get you a Git repository with the complete history and all the branches and tags intact.

    As usual, make backups of anything that might be touched by this before doing any of this stuff, and proceed at your own risk, etc.

    As the answer provided, I found that there will be the problem when already fetch all revisions to Git. Create new issue like this topic

    After I reviewed the repository, I found that if I provide the parameter (-s) to mark my repository as standard repository, it will ignore for all non-standard, in my case, it will ignore Rev.1-700 and will automatic convert from 700 afterward.

    So, right now, I still have no solution except use git-svn with the full fetch from the original url and ignore the path that make the problem occurs.

    Git Baby is a git and github fan, let's start git clone.