Skip to content

Instantly share code, notes, and snippets.

@shrwnsan
Created November 9, 2012 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrwnsan/4047242 to your computer and use it in GitHub Desktop.
Save shrwnsan/4047242 to your computer and use it in GitHub Desktop.
Convert SVN repository to Git
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp
cd ~/temp
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'
git init --bare ~/new-bare.git
cd ~/new-bare.git
git symbolic-ref HEAD refs/heads/trunk
cd ~/temp
git remote add bare ~/new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
cd ~/new-bare.git
git branch -m trunk master
cd ~/new-bare.git
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
@shrwnsan
Copy link
Author

shrwnsan commented Nov 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment