Skip to content

Instantly share code, notes, and snippets.

@tfnico
Last active December 21, 2015 13:19
Show Gist options
  • Save tfnico/6312157 to your computer and use it in GitHub Desktop.
Save tfnico/6312157 to your computer and use it in GitHub Desktop.
Instructions on how to port Dukto from SVN to Git
First create an author-map file for translating svn user names to Git user names in history:
$ cat author-map
em.colombo = Emanuele Colombo <[email protected]>
[email protected] = Emanuele Colombo <[email protected]>
Vittorio.Curcio = Vittorio Curcio <[email protected]>
xxdede = xxdede <[email protected]>
(no author) = no author <[email protected]>
Now, do a git svn clone:
$ git svn clone -s --prefix=mirror/ http://dukto.googlecode.com/svn/ --no-metadata -A author-map dukto
This will take a little while.
After we're done, we still want to clean up a little. For example, convert SVN tags to proper Git tags. Run this script:
git for-each-ref --format="%(refname)" refs/remotes/mirror/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 for-each-ref --format="%(contents)" "$tag")" \
${tag#refs/remotes/mirror/tags/} "$tag"
done
and delete all the branches that have now been converted to tags:
$ git for-each-ref --format='%(refname:short)' 'refs/remotes/mirror/tags/'|xargs git branch -rD
And delete some dummy branches that we won't need:
$ git branch -Dr mirror/resources@105
$ git branch -Dr mirror/trunk # local branch master is the same as trunk
And delete some tags that we don't want:
$ git tag -d R1@16
$ git tag -d R2@38
$ git tag -d R3.1@100
$ git tag -d R3@93
$ git tag -d R4@103
Now, create a repository called "dukto" on GitHub. Leave it empty (don't add any README or something like that).
Add the GitHub repo as a remote:
$ cd dukto
$ git remote add github [email protected]:username/dukto.git
Push all the SVN branches and tags to the remote:
$ git push github master
$ git push github 'refs/remotes/mirror/*:refs/heads/*'
$ git push github --tags
Now you can clone a fresh nice pure Git repo and get to work!
$ git clone [email protected]:username/dukto.git
$ cd dukto
$ # do changes
$ git commit -am "Changes"
$ git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment