Skip to content

Commit 96434e3

Browse files
author
Jordan McCullough
committed
Merge pull request #248 from github/cheatsheet-subversion-migration
Subversion migration cheat sheet (first edition)
2 parents d2be422 + ca0d80f commit 96434e3

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

downloads/subversion-migration.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Subversion to Git migration
2+
3+
From understanding the vocabularies of Subversion and Git technologies to migrating a project to GitHub, this cheat sheet can help.
4+
5+
6+
## Vocabulary
7+
8+
| Git command | SVN | SVN equivalent | Git Behavior |
9+
|---|---|---|---|
10+
| `status` || status | Report the state of working tree |
11+
| `add` || add | Required for each path before making a commit |
12+
| `commit` || commit | Store prepared changes in local revision history |
13+
| `rm` || `rm`, `delete` | Prepare paths for deletion in next commit |
14+
| `mv` || `move` | Prepare relocated content for next commit |
15+
| `branch` || | Create local context for commits |
16+
| `checkout` || | Switch branches, or rewrite working tree from commit |
17+
| `merge` || | Join branch histories and changes to working tree |
18+
| `log` || | No network required |
19+
| `clone` || `checkout` | Acquire the entire history of a project locally for the first time |
20+
| `push` || `commit` | Upload commit history to GitHub/centralized Git host |
21+
| `pull` || | Download and integrate GitHub repository history with local one |
22+
| `fetch` || | Download GitHub repository history with no other action |
23+
24+
**Key:** ✓ yes, ✗ no, — partial
25+
26+
## Leveraging Git's support of SVN
27+
During a VCS change, there may be a need to begin using Git locally while the hosted repositories remain under Subversion control. The `git svn` command and sub-commends provide the ability to interact with Subversion's repositories while using all the benefits of Git on the command line or with graphical clients.
28+
29+
Acquire an SVN repository, with a resulting Git repository locally:
30+
31+
`git svn clone [svn-repo-url]`
32+
33+
**Note:** Keep in mind the *layout* of the SVN repository and whether this follows the standard pattern or not. If the Subversion repository follows the traditional `trunk`, `branches`, and `tags` pattern, supply the `--std-layout` option. When the Subversion repository is non-standard or organized in a more custom structure, the following options switches should be specified during the clone:
34+
35+
* `-T [trunk]` for alternate main source convention
36+
* `-b [branches]` for alternate branch location
37+
* `-t [tags]` for alternate tag structure location
38+
39+
Once the clone operation completes, you can proceed with any standard Git interactions, commands and processes.
40+
41+
## Synchronizing with SVN repository
42+
43+
Once local history within a `git svn clone` repository has occurred, the commits must be published to the Subversion repository.
44+
45+
`git svn dcommit`
46+
47+
If the Subversion repository has commits not yet on the local Git-equivalent, a `rebase` must first be performed.
48+
49+
`git svn rebase`
50+
51+
Keep in mind this rewrites local Git history and your Git commit refs will be different than before the command is run.
52+
53+
## Subversion tooling bridge via GitHub
54+
55+
For users familiar with Subversion toolsets and clients, [GitHub fully supports and bridges communications to the central repository](https://help.github.com/articles/support-for-subversion-clients/). All Subversion commits directed at a GitHub hosted repository will automatically be converted to Git commits.
56+
57+
* [Topics about branch strategies with SVN](https://github.com/blog/1178-collaborating-on-github-with-subversion)
58+
* Patterns for updating `trunk` or GitHub default branch equivalent
59+
60+
61+
## Migrating
62+
63+
The use of `git svn` should be a temporary bridge and complete migration to Git repositories for both local and upstream destinations is optimal.
64+
65+
The most lightweight approach is by utilizing `git svn` as a one-time conversion from Subversion to Git repository. To migrate a Subversion repository, several aspects must be ensured:
66+
67+
* Subversion commits cease prior to initiating the process
68+
* One machine serves as intermediary during conversion
69+
* GitHub "upstream" repository intialized and ready to receive history, branches, tags
70+
71+
### Git-SVN conversion method
72+
* Create email/username mapping file
73+
* Begin `git svn clone`
74+
* Add `git remote add origin [GitHub-URL]`
75+
76+
Run each `ref` publish separately:
77+
78+
* Run `git push --all origin`
79+
* Run `git push --tags origin`
80+
81+
Or upload all `ref`s (branches, tags,) to upstream:
82+
83+
* `git push --mirror origin`
84+
85+
### SVN2Git method
86+
87+
* Install Ruby Gem [SVN2Git](https://github.com/nirvdrum/svn2git)
88+
* Identify the projects in the Subversion repository
89+
* Run `svn list [svn-repo-url]`
90+
* Start `svn2git [repo-root|repo-root/project]`
91+
92+
Considerations on migration:
93+
94+
* Convert "flat" history across all projects
95+
* Utilize Git `filter-branch --subdirectory-filter`
96+
* Migrate on a project-by-project basis
97+
* Use `--trunk`, `--nobranches`, `--notags` or `--rootistrunk` for non-standard layouts
98+
* Limit history from starting point ``--revision <<starting_rev>>``, or range `--revision <<start:end>>`
99+
100+
https://github.com/nirvdrum/svn2git
101+
102+
### GitHub importer (Porter) method
103+
* [Read the import tool documentation](https://help.github.com/articles/importing-from-other-version-control-systems-to-github/)
104+
* Expose the Subversion repository publicly
105+
* [Visit the GitHub import tool page](https://porter.github.com/new)
106+
* Point the import tool at your Subversion, TFS, or Mercurial repository
107+
* Create the username mappings
108+
* Wait for the tool to work in the background and complete the conversion

0 commit comments

Comments
 (0)