Importing SVN folder structure into Git Repo without history and users

I'm looking for a simple approach to import some legacy SVN code (which, although in an SVN folder structure containing branches / tags and a trunk, doesn't have any .svn folders, and therefore doesn't contain user history or SVN, etc.) etc.). We have all the old SVN code with no .svn folders and no access to the original SVN repo.

+3


source to share


2 answers


Ok, if you only have the latest version with no history, your best bet is to just import it into git as new code.

You don't know the relationship between branches and tags, so you can just import them as a separate root, or you can try to reconstruct the relationship from obvious properties, like every version based on the previous one.

So you just create an empty git repository and then for each branch / tag you:



  • Prepare the appropriate branch.

    • The new repository starts on a branch master

      without a parent. What you import trunk

      , but before that you import the tags that you know precede this.
    • You create a new branch from a known base using the git checkout -b

      new-name base . For example, if you know that a branch is based on a specific version.
    • You are creating a new branch without a parent using git checkout --orphan

      new-name. For cases where you don't know what the branch is based on. See git-checkout .
  • Remove previous content: git rm -rf .

  • Copy the contents of the SVN branch / tag.

  • Add all git add .

  • Message: git commit -m

    .

  • Rinse and repeat until the end.

You can easily script if you don't need relationships. If you want to recover some history, eg. that the master will successfully complete release 3, which in turn will successfully release 2 and release 1, you will have to manually order and select branches.

You can also just git init

+ git add .

+ git commit

in each directory and push each to one central repo under the appropriate name, but this will not allow you to restore history.

+1


source


The directories .svn

contain the latest checked version of the files in your project. In theory, this is something like the content of the commit that points HEAD

to Git. Subversion uses the information to know which files have changed (and show the differences) and revert the files to their latest updated (checked) version.

Since you don't have access to the Subversion repository, the contents of the directories are .svn

almost useless.

Delete directories .svn

, then to the root directory of your project:



git init
git add .
git commit -m "the initial import"

      

Replace the text "initial import" with any commit message you want.

More on Git Commands: https://git-scm.com/docs

+1


source







All Articles