How to convert SVN repository to git Repository

Source: Internet
Author: User

From: http://rongjih.blog.163.com/blog/static/3357446120107111449543/
Get ready:Sudo apt-Get install Git-SVN Follow these steps to convert the svn repository to a git Repository:1) Move the remote SVN repository to the Local Machine (this step is mainly used to increase the conversion speed and can be ignored). Refer to this article:

The http://rongjih.blog.163.com/blog/static/335744612010620105546475/ here assumes that the final SVN repository to be converted is file: // tmp/test-SVN
2) use the git svn clone command to start converting $ git SVN clone file: /// tmp/test-svn-T trunk-B branches-T tags git SVN clone command will import the entire subversion repository to a local git repository. This is equivalent to running two commands git SVN init and gitsvn fetch for the provided URL. Because git needs to extract each version, one at a time, and then submit one by one. For a project that contains hundreds of thousands of submissions, the time spent may be several hours or even several days (If your SVN repository is accessed remotely, it is advantageous to execute the first step first. However, projects are usually submitted many times, and long waits are indispensable. Please wait ). -T trunk-B branches-T tags tells git that the Subversion repository follows the basic branch and label naming rules. If your trunk (trunk, equivalent to the master branch in git, representing the main line of development), branches or labels are named in different ways, you should change accordingly. Because of the adequacy of this rule, you can use-s to replace the entire command, which means that the Standard Layout (S is standard
The first letter of layout), that is, the content of the preceding options. The following command has the same effect: $ git SVN clone file: // tmp/test-svn-s pay attention to the remote reference imported through git Svn in this example, the Subversion tag is added as a remote branch, rather than a real git tag. The imported subversion repository seems to have a Tags Remote Server with different branches. You can use "$ git show-Ref" to view the GIT repository after conversion. The results are similar to the following: $ git show-ref1cbd4904d9982f386d87f88fce1c24ad7c0f0471 refs/heads/masteraee1ecc26318164f355a883f5d99cff0c852d3c4 refs/remotes/my-calc-branch03d09b0e2aad427e34a6d50ff147128e76c0e0f5 refs/remotes/tags/2.0.250d02cc0adc9da4319eeba090020.ba219b9c376 refs/remotes/tags/release-2.0.14caaa711a50c77879a91b8b90380060f672745cb refs/remotes/tags 4c513ff1214c3488abe66dcb92916f refs/remotes/tags/release-2.0.2rc11cbd4904d9982f386d87f88fce1c24ad7c0f0471 refs/remotes/trunk and the general git repository is similar to the following: $ git show-ref83e38c7a0af325a9722f2fdc56b10188806d83a1 refs/heads/master3e15e38c198baac84223acfc6224bb8b99ff2281 refs/remotes/gitserver/inclurefs/remotes/ORIGIN/inclurefs/Re Motes/ORIGIN/testing has two remote servers: one is gitserver and has one master branch. The other is origin and has two branches: Master and testing.
3) obtain the latest update from the svn server to the converted git repository (this step is usually unnecessary During Continuous Conversion) $ git SVN rebase
4) convert the svn: Ignore attribute of the svn repository to the GIT repository. gitignore File $ git SVN create-ignore this command automatically creates the corresponding. the gitignore file so that it can be included in the next submission. If you want to check the. gitignore file before generating it, run the command "Git SVN show-Ignore.
5) convert the svn tag to the GIT tag $ CP-RF. git/refs/remotes/tags /*. git/refs/tags/$ Rm-RF. git/refs/remotes/tags this command turns the index of the remote branch originally started with Tag/into a real (lightweight) Tag.

If this problem persists in the window, "CP: cannot stat" is reported '. the error of git/refs/remotes/tags/* ': no such file or directory "can be handled using the following two standard commands: $ git tag tagname tags/tagname ---- create a git tag with the specified branch $ git branch-r-D tags/tagname ---- Delete the specified remote Branch
6) Switch SVN branch to git branch $ CP-RF. git/refs/remotes /*. git/refs/heads/$ Rm-RF. git/refs/remotes this command turns the remaining indexes under refs/remotes into local git Branch

7) finally, push the converted local git repository to the public git server $ git remote add origin [remote git server address] $ git push origin master -- all the tags labels and trunk should be neat now it is lying in the new git server. If you want to synchronize the branches to the remote git server, change -- tags to -- all.

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.