Tuesday, July 23, 2013

HOWTO Migrate from SVN to GIT. A brief guide

I post it here as it would be pity to loose.

Read this first:
http://john.albin.net/git/convert-subversion-to-git


# create authors mapping file
cd
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

# edit authors-transform.txt
# user name format:
# svn_user = git_user

# clone SVN repository into Git's
git svn clone -s https://jlwv.svn.beanstalkapp.com/ -A /authors-transform.txt --stdlayout

# push repository to a bare git repository
git init --bare
cd
git symbolic-ref HEAD refs/heads/trunk

cd
git remote add bare
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare

# rename “trunk” branch to “master”
cd
git branch -m trunk master

# clean up branches and tags
git for-each-ref --format='%(refname)' refs/heads/tags |
cut -d / -f 4 |
while read ref; do
git tag "$ref" "refs/heads/tags/$ref";
git branch -D "tags/$ref";
done

# GitHub specific:

git remote add origin https://github.com/
git push -u origin master
# git push origin branch1 branch2 tag1 tag2... for each branch/tag
# do not use --all/--tags switch, otherwise will have to deal with a lot of crap

No comments:

Post a Comment