Created
November 9, 2012 18:09
-
-
Save shrwnsan/4047242 to your computer and use it in GitHub Desktop.
Convert SVN repository to Git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd ~/temp | |
| git svn show-ignore > .gitignore | |
| git add .gitignore | |
| git commit -m 'Convert svn:ignore properties to .gitignore.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git init --bare ~/new-bare.git | |
| cd ~/new-bare.git | |
| git symbolic-ref HEAD refs/heads/trunk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd ~/temp | |
| git remote add bare ~/new-bare.git | |
| git config remote.bare.push 'refs/remotes/*:refs/heads/*' | |
| git push bare |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd ~/new-bare.git | |
| git branch -m trunk master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Complete write-up @ http://justamemo.com/2012/11/09/svn-to-git-repository/