SkyrimForge.com
Mods
Authors
Forums
Wiki
Store
Paste
Sign in
Register new account
SkyrimForge.com Wiki
Repositories
/
Convert SVN to GIT
r8
Source
Markup:
**Note:** This article currently has a high "know what you do" factor, and servers mostly as an outline of what to do and how to automate some of the tedious steps. If you have any questions, feel free to drop by on irc.freenode.net #curseforge and ping charon. ==Converting a SVN repository to GIT== Note: You may need to use git-svn on Linux as there are reports that it is broken on Windows. YMMV. You can also try both the mingw port and a cygwin install and see if at least one works. Do //not// switch your repository type to Git before you are satisfied with the conversion result, so that you can re-clone if something goes wrong! * Develop an author map file which contains the lines for each user who has submitted a commit to your SVN repository: <<code text>> svnuser = R. E. Alname <real@email.example.com> <</code>> You can automate some of the task by running <<code sh>> svn log svn://svn.example.com/game/project/mainline | sed -ne 's/^r[^|]*| \([^ ]*\) |.*$/\1 = \1 <\1@dummy.example.com>/p' | sort -u > author-map <</code>> which will scan the SVN history for all users, and make a dummy line for each. You can then look up their real names and emails as required. * Run the following command to import the SVN repository into a GIT repository: <<code sh>> git svn clone -A author-map --no-metadata -s svn://svn.example.com/game/project/mainline project <</code>> * Fix up the history until satisfied. * Change the repository on the web-page to GIT. * Run the following commands to add your GIT repository: <<code sh>> git remote add origin git@git.example.com:game/project/mainline.git git push origin master <</code>> ==How to fix the history== ===Remove useless commits=== ====Transition from old repository to new repository==== * Make a graft that removes the commits that you do not want. Grafts are "fake parents" and can be used to remove emtpy commits, glue together disconnected history and even rebuild (simple) SVN merges as "real" Git merges. See man gitrepository-layout for usage. ====Remove the project name from commit notes==== On the old repository, you had to preface all your commit notes with the project name. This will get rid of them all. It will also drop empty commits, and set all grafts from the previous step "in stone". * Run the command: <<code sh>> git filter-branch --prune-empty --tag-name-filter cat --msg-filter 'perl -pe "s/^project:\s*//"' -- --all <</code>> ===Create a tag for the branches=== * Run the following command: <<code sh>> git for-each-ref --format="%(refname)" refs/remotes/tags/ | while read tag; do GIT_COMMITTER_DATE="$(git log -1 --pretty=format:"%ad" "$tag")" GIT_COMMITTER_EMAIL="$(git log -1 --pretty=format:"%ce" "$tag")" GIT_COMMITTER_NAME="$(git log -1 --pretty=format:"%cn" "$tag")" git tag -m "$(git log -1 --pretty=format:"%s%n%b" "$tag")" ${tag#refs/remotes/tags/} "$tag"; done <</code>> The net effect is to convert SVN "tags" to annotated Git tags, preserving the tagger identity and timestamp. ==Converting with Ruby== Please see [[http://github.com/jcoglan/svn2git/tree/master|this page]] for information on how to do this with Ruby.
Markup Type:
The type of markup for this entry.
Click here for details
.
BBCode
Markdown
Plain Text
Safe HTML
WikiCreole
<div><img src="//secure-us.imrworldwide.com/cgi-bin/m?ci=us-603339h&cg=0&cc=1&ts=noscript" width="1" height="1" alt="" /></div>