SVN migration to Git

Source: Internet
Author: User

SVN repository migration, as long as the SVN library for the standard directory (trunk, branches, tags) according to the official Git document can be completed.

Here's the SVN repository of the nonstandard directory structure I migrated

SVN repository has part1 directory, Part1 directory is divided into: Code, UI and so on, for this non-standard directory structure, the backbone is part1, no branch, no tags.

and code below is divided into Android, iOS directory, directory within the want $ trunk, tags, branch, this directory hierarchy ...


For the above non-standard directory structure, I used git svn to local, and commit to a full version of the Git repository, and then split the directory hierarchy into a separate standard directory structure of the SVN repository, and then the various libraries git svn to local, and then commit to the GIT library.

That may be a bit of a detour, specifically to operate under

Global assumptions:

Original SVN library Address: file:///home/svn1/

Post-split standard library address: file:///home/svn2/$SVN/

Git address for the original SVN repository: https://git.example.com/dev/oldsvn.git

After splitting the corresponding git address: [email protected]/dev/$svn. git


Note:$svn named with a specific directory or library name

Directory structure:

Part1:

Code:

android:trunk, tags, branches

iOS:trunk, tags, branches

UI


Clone the original SVN repository to Local:

For a standard directory structure that contains other custom directories, you can also use this method to set the trunk to a custom directory name

Git svn clone file:///home/svn/--authors-flie=users.txt--no-metadata--trunk=part1 oldsvn

Option meaning:

--authors-file : Specify SVN and git user correspondence

--no-metadata: tell me git svn not to include metadata that Subversion typically imports

--trunk: trunk Name

Note: There are no tags and branches so do not add--tags--branch option, also do not use the-s option instead. Non-standard directory structure, the actual existence of what is specified, does not exist unspecified.

In the clone process, there may be a ' GC ' hint, meet then ' git GC--prune=now ', and then ' git svn fetch ' to continue clone

After success, the cloned GIT repository structure corresponds to:

Code:

android:trunk, tags, branches

iOS:trunk, tags, branches

UI

Submit this to the Git repository as an old repository for easy review of the original SVN history commit changes.

Git remote add Origin https://git.example.com/dev/oldsvn.git
Git push Origin--all


For multi-tiered directory structures, such as the need to migrate Part1:conde:ios libraries to Git now

First, copy the iOS directory to the root directory of the SVN repository, both with the part1 sibling, and the directory organization as follows:

Part1:

Code:

android:trunk, tags, branches

iOS:trunk, tags, branches

UI

android:trunk, tags, branches

iOS:trunk, tags, branches

Ui:


This allows you to specify the trunk as iOS when you pass ' git svn clone '.

Git svn clone file:///home/svn/--authors-flie=users.txt--no-metadata--trunk=ios--branch=branches--tags=tags iOS


Change the label to the appropriate Git tag

$ cp-rf. git/refs/remotes/origin/tags/*. git/refs/tags/$ rm-rf. Git/refs/remotes/origin/tags

This causes the remotes/origin/tags/ remote Branch reference in the original to become a true (lightweight) label.

Next, refs/remotes move the remaining references below to the local branch:

$ cp-rf. git/refs/remotes/*. git/refs/heads/$ rm-rf. git/refs/remotes

Add your new Git server as a remote repository and push it to the top

git remote add origin [email protected]/dev/ios.gitgit Branch-rgit Push Origin--all


It can take a lot of time to change the SVN directory, so you can also keep the original SVN directory structure for cloning

Git svn clone file:///home/svn/part1/code/android--authors-flie=users.txt--no-metadata-t trunk-t tags-b branches and Roid

With this approach, there may be an unknown problem that I'm encountering

Fatal:refs/remotes/trunk:not a valid SHA1

The above issues have not been resolved

SVN migration to Git

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.