|
| 1 | +== svn2git |
| 2 | + |
| 3 | ++svn2git+ is a tiny utility for migrating projects from Subversion to Git while keeping |
| 4 | +the trunk, branches and tags where they should be. It uses git-svn to clone an svn repository |
| 5 | +and does some clean-up to make sure branches and tags are imported in a meaningful way, and |
| 6 | +that the code checked into master ends up being what's currently in your svn trunk rather |
| 7 | +than whichever svn branch your last commit was in. |
| 8 | + |
| 9 | +=== Examples |
| 10 | + |
| 11 | +Say I have this code in svn: |
| 12 | + |
| 13 | + trunk |
| 14 | + ... |
| 15 | + branches |
| 16 | + 1.x |
| 17 | + 2.x |
| 18 | + tags |
| 19 | + 1.0.0 |
| 20 | + 1.0.1 |
| 21 | + 1.0.2 |
| 22 | + 1.1.0 |
| 23 | + 2.0.0 |
| 24 | + |
| 25 | +git-svn will go through the commit history to build a new git repo. It will import all branches |
| 26 | +and tags as remote svn branches, whereas what you really want is git-native local branches and |
| 27 | +git tag objects. So after importing this project I'll get: |
| 28 | + |
| 29 | + $ git branch |
| 30 | + * master |
| 31 | + $ git branch -a |
| 32 | + * master |
| 33 | + 1.x |
| 34 | + 2.x |
| 35 | + tags/1.0.0 |
| 36 | + tags/1.0.1 |
| 37 | + tags/1.0.2 |
| 38 | + tags/1.1.0 |
| 39 | + tags/2.0.0 |
| 40 | + trunk |
| 41 | + $ git tag -l |
| 42 | + [ empty ] |
| 43 | + |
| 44 | +After svn2git is done with your project, you'll get this instead: |
| 45 | + |
| 46 | + $ git branch |
| 47 | + * master |
| 48 | + 1.x |
| 49 | + 2.x |
| 50 | + $ git tag -l |
| 51 | + 1.0.0 |
| 52 | + 1.0.1 |
| 53 | + 1.0.2 |
| 54 | + 1.1.0 |
| 55 | + 2.0.0 |
| 56 | + |
| 57 | +Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo. |
| 58 | + |
| 59 | +=== Installation |
| 60 | + |
| 61 | +Make sure you have git installed, then install the gem: |
| 62 | + |
| 63 | + $ sudo apt-get install git-core git-svn |
| 64 | + $ sudo gem install svn2git |
| 65 | + |
| 66 | +=== Usage |
| 67 | + |
| 68 | +To create a git repo from an existing svn repo: |
| 69 | + |
| 70 | + $ svn2git http://svn.yoursite.com/path/to/repo |
| 71 | + |
| 72 | +This will create a new directory called +repo+ containing the git version of the repository. |
| 73 | +If you're not using the standard trunk/branches/tags layout, you can pass arguments to tell |
| 74 | +git-svn what to look for: |
| 75 | + |
| 76 | + $ svn2git http://svn.yoursite.com/path/to/repo trunk=the_trunk tags=taggings |
| 77 | + |
| 78 | +=== GitHub integration |
| 79 | + |
| 80 | +When creating your new git repo, svn2git can push your new repo to github.com if you pass |
| 81 | +in your username and project name. For example: |
| 82 | + |
| 83 | + $ svn2git http://svn.jcoglan.com/packr github=jcoglan/packr |
| 84 | + |
| 85 | +You need to make sure the project exists on github before running this, and make sure you |
| 86 | +have your SSH key set up or this won't work. |
| 87 | + |
0 commit comments