Category: Subversion
Converting Assembla SVN repositor to GIT
			GITSubversion
	
Converting Assembla SVN repositor to GIT
Move a subversion repository, hosted at Assembla to GIT , For this, we expect that you already have a GIT server and repository setup with permission for you to write to it. there is an error to make sure it is 100% clean)
- first create 4 directories
 
- /data/code/svndump – to download your subversion repositories into
 - /data/code/tmpsvn – to load your temporary subversion repository into after downloading
 - /data/code/tmpgit1 – to create a temp git repository from your svn repo
 - /data/code/tmpgit2 – to create a bare reformatted git repository from your first git
 - first open the project / repo in assembla
 - Click Import / Export > Download Dump
 - right click on the link and copy link then open command line on a machine with svn and git
 
- cd /data/code wget -O svndump/myrepo.gz “https://linkcopoiedfromassempla” # download the file with quotes (to escape ampersands
 - svnadmin create tmpsvn/myrepo #create an empt repositorycd
 - gunzip -c svndump/myrepo.gz | svnadmin load tmpsvn/myrepo
 - svn log -q file://data/code/tmpsvn/myrepo | awk -F ‘|’ ‘/^r/ {sub(“^ “, “”, $2); sub(” $”, “”, $2); print $2″ = “$2” <“$2″>”}’ | sort -u > users.txt
 - git svn clone file:///data/code/tmpsvn/myrepo/ –no-metadata -A users.txt –stdlayout tmpgit1/myrepo
 - cd tmpgit1/myrepo
 - touch .gitignore #if I dont have any ignore files
 - git svn show-ignore > .gitignore #if I do have ignore files i svn, this will return an error if there are no ignore files
 - git add .gitignore
 - git commit -m ‘Converting Properties from SVN to GIT’ .gitignore
 - cd /data/code
 - mkdir tmpgit2/myrepo
 - cd tmpgit2/myrepo
 - git init –bare
 - git symbolic-ref HEAD refs/heads/trunk
 - Go back to the tmpgit1 repo and push it to the new bare repo and rename the ‘trunk’ to ‘master’
 - cd ../../tmpgit1/myrepo
 - git remote add bare /data/code/tmpgit2/myrepo
 - git config remote.bare.push ‘refs/remotes/*:refs/heads/*’
 - git push bare
 - cd /data/code/tmpgit2/myrepo
 - git branch -m trunk master
 - Clean up branches and tags (thanks to http://john.albin.net/git/convert-subversion-to-git for most of this)
 
- 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
Now you have a correctly formatted repo at /data/code/tmpgit2/myrepo you can push it to your final git repository
- git remote add origin <your final git repository url >
 - git push origin master
 
This may take a bit of time depending on how much code you have. But once it is complete you can browse your repository in stash.
