|
3 | 3 | [](https://ci.appveyor.com/project/mazong1123/svn2gitnet)
|
4 | 4 | [](https://travis-ci.org/mazong1123/svn2gitnet)
|
5 | 5 |
|
6 |
| -**SVN2GIT.NET** started as a .NET implementation of [svn2git](https://github.com/nirvdrum/svn2git). It intends to provide a simple and easy way to migrate projects from svn to git. |
| 6 | +**SVN2GIT.NET** started as a .NET re-implementation of [svn2git](https://github.com/nirvdrum/svn2git). It intends to provide a simple and easy way to migrate projects from svn to git. |
| 7 | + |
| 8 | +It is based on `git-svn` so please make sure it has been installed. |
| 9 | + |
| 10 | +## Examples |
| 11 | + |
| 12 | +Say if we have this code in svn: |
| 13 | + |
| 14 | + trunk |
| 15 | + ... |
| 16 | + branches |
| 17 | + 1.x |
| 18 | + 2.x |
| 19 | + tags |
| 20 | + 1.0.0 |
| 21 | + 1.0.1 |
| 22 | + 1.0.2 |
| 23 | + 1.1.0 |
| 24 | + 2.0.0 |
| 25 | + |
| 26 | +`git-svn` will go through the commit history to build a new git repo. It will |
| 27 | +import all branches and tags as remote svn branches, whereas what you really |
| 28 | +want is git-native local branches and git tag objects. So after importing this |
| 29 | +project we'll get: |
| 30 | + |
| 31 | + $ git branch |
| 32 | + * master |
| 33 | + $ git branch -a |
| 34 | + * master |
| 35 | + 1.x |
| 36 | + 2.x |
| 37 | + tags/1.0.0 |
| 38 | + tags/1.0.1 |
| 39 | + tags/1.0.2 |
| 40 | + tags/1.1.0 |
| 41 | + tags/2.0.0 |
| 42 | + trunk |
| 43 | + $ git tag -l |
| 44 | + [ empty ] |
| 45 | + |
| 46 | +After `svn2gitnet` is done with your project, you'll get this instead: |
| 47 | + |
| 48 | + $ git branch |
| 49 | + * master |
| 50 | + 1.x |
| 51 | + 2.x |
| 52 | + $ git tag -l |
| 53 | + 1.0.0 |
| 54 | + 1.0.1 |
| 55 | + 1.0.2 |
| 56 | + 1.1.0 |
| 57 | + 2.0.0 |
| 58 | + |
| 59 | +Finally, it makes sure the HEAD of master is the same as the current trunk of |
| 60 | +the svn repo. |
| 61 | + |
| 62 | +## Installation |
| 63 | + |
| 64 | +### Windows |
| 65 | + |
| 66 | +- Option 1: Download `.msi` file in the [release page](https://github.com/mazong1123/svn2gitnet/releases). Double click to install it. **Note: There's no "Next" or "Finish" button during the installation process. If it finished, just open a command line window, type `svn2gitnet --help` to verify the installation. I'll add wizard dialog during installation in the upcoming release.** |
| 67 | + |
| 68 | +- Option: 2: Download `zip` file in the [release page](https://github.com/mazong1123/svn2gitnet/releases). Extract the zip, and add the folder to `PATH` environment variable. Open command line window and type `svn2gitnet --help`. |
| 69 | + |
| 70 | +### Mac and *nix |
| 71 | + |
| 72 | +Download the correct `tar.gz` file according to your OS. |
| 73 | + |
| 74 | +Extract it via: |
| 75 | + |
| 76 | +``` |
| 77 | +tar -zxvf yourosname.tar.gz |
| 78 | +``` |
| 79 | + |
| 80 | +Add the folder to the environment path: |
| 81 | + |
| 82 | +```sh |
| 83 | +PATH=$PATH:yourfolderpath |
| 84 | +``` |
| 85 | + |
| 86 | +Type `svn2gitnet --help` to verify the installation. |
| 87 | + |
| 88 | +## How to use |
| 89 | + |
| 90 | +### Initial Conversion |
| 91 | + |
| 92 | +There are several ways you can create a git repo from an existing |
| 93 | +svn repo. The differentiating factor is the svn repo layout. Below is an |
| 94 | +enumerated listing of the varying supported layouts and the proper way to |
| 95 | +create a git repo from a svn repo in the specified layout. |
| 96 | + |
| 97 | +1. The svn repo is in the standard layout of (trunk, branches, tags) at the |
| 98 | +root level of the repo. |
| 99 | + |
| 100 | + $ svn2gitnet http://svn.example.com/path/to/repo |
| 101 | + |
| 102 | +2. The svn repo is NOT in standard layout and has only a trunk and tags at the |
| 103 | +root level of the repo. |
| 104 | + |
| 105 | + $ svn2gitnet http://svn.example.com/path/to/repo --trunk dev --tags rel --nobranches |
| 106 | + |
| 107 | +3. The svn repo is NOT in standard layout and has only a trunk at the root |
| 108 | +level of the repo. |
| 109 | + |
| 110 | + $ svn2gitnet http://svn.example.com/path/to/repo --trunk trunk --nobranches --notags |
| 111 | + |
| 112 | +4. The svn repo is NOT in standard layout and has no trunk, branches, or tags |
| 113 | +at the root level of the repo. Instead the root level of the repo is |
| 114 | +equivalent to the trunk and there are no tags or branches. |
| 115 | + |
| 116 | + $ svn2gitnet http://svn.example.com/path/to/repo --rootistrunk |
| 117 | + |
| 118 | +5. The svn repo is in the standard layout but you want to exclude the massive |
| 119 | +doc directory and the backup files you once accidently added. |
| 120 | + |
| 121 | + $ svn2gitnet http://svn.example.com/path/to/repo --exclude doc --exclude '.*~$' |
| 122 | + |
| 123 | +6. The svn repo actually tracks several projects and you only want to migrate |
| 124 | +one of them. |
| 125 | + |
| 126 | + $ svn2gitnet http://svn.example.com/path/to/repo/nested_project --no-minimize-url |
| 127 | + |
| 128 | +7. The svn repo is password protected. |
| 129 | + |
| 130 | + $ svn2gitnet http://svn.example.com/path/to/repo --username <<user_with_perms>> --password <<password>> |
| 131 | + |
| 132 | +8. You need to migrate starting at a specific svn revision number. |
| 133 | + |
| 134 | + $ svn2gitnet http://svn.example.com/path/to/repo --revision <<starting_revision_number>> |
| 135 | + |
| 136 | +9. You need to migrate starting at a specific svn revision number, ending at a specific revision number. |
| 137 | + |
| 138 | +```sh |
| 139 | + svn2gitnet http://svn.example.com/path/to/repo --revision <<starting_revision_number>>:<<ending_revision_number>> |
| 140 | +``` |
| 141 | +
|
| 142 | +10. Include metadata (git-svn-id) in git logs. |
| 143 | +
|
| 144 | +```sh |
| 145 | +svn2gitnet http://svn.example.com/path/to/repo --metadata |
| 146 | +``` |
| 147 | +
|
| 148 | +The above will create a git repository in the current directory with the git |
| 149 | +version of the svn repository. Hence, you need to make a directory that you |
| 150 | +want your new git repo to exist in, change into it and then run one of the |
| 151 | +above commands. Note that in the above cases the trunk, branches, tags options |
| 152 | +are simply folder names relative to the provided repo path. For example if you |
| 153 | +specified trunk=foo branches=bar and tags=foobar it would be referencing |
| 154 | +http://svn.example.com/path/to/repo/foo as your trunk, and so on. However, in |
| 155 | +case 4 it references the root of the repo as trunk. |
| 156 | +
|
| 157 | +### Repository Updates |
| 158 | +
|
| 159 | +to pull in the latest changes from SVN into your |
| 160 | +git repository created with svn2git. This is a one way sync, but allows you to use svn2git |
| 161 | +as a mirroring tool for your SVN repositories. |
| 162 | +
|
| 163 | +The command to call is: |
| 164 | +
|
| 165 | +```sh |
| 166 | +svn2git --rebase |
| 167 | +``` |
0 commit comments