Created
September 5, 2025 23:53
-
-
Save akochepasov/57e05fa6e71fd3ae73e47e83681b1b66 to your computer and use it in GitHub Desktop.
svn2git
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
| # Main idea | |
| 1 get authors | |
| svn log -q | awk -F '|' '/^r/ {gsub(/ /, "", $2); sub(" $", "", $2); print $2" = "$2" <"$2"@email.com>"}' | sort -u > users.txt | |
| 2 clone svn | |
| git svn clone --prefix=svn/ --stdlayout --no-metadata --authors-file=users.txt https://svn_server/svn/repo | |
| 3 add new origin | |
| git remote add origin [email protected]:user/repo.git | |
| git push -u origin --all | |
| # More clones | |
| ## Absolute | |
| git svn clone --prefix=svn/ --stdlayout --no-metadata --authors-file=users.txt --trunk="MyTools/Trunk" --tags="MyTools/Trunk/Tag" --branches="MyTools/Trunk/Branches" https://svn_server/svn/repo/ clone_dir.git | |
| # Relative | |
| git svn clone --prefix=svn/ --stdlayout --no-metadata --authors-file=users.txt --trunk=Trunk --tags=Tag --branches=Branches https://svn_server/svn/repo ProjectName24 clone_dir.git | |
| # Add branches and trunks | |
| git svn init https://svn_server/svn/repo -T Trunk -b Branches -t Tag | |
| # Fetch tags one by one | |
| git checkout -b tag_v1.1 svn/tags/1.1 | |
| # Fetch checked out branch | |
| git svn fetch | |
| # Convert all branch to local ones | |
| for t in `git branch -r | grep 'tags/' | sed s_svn.tags/__` ; do git checkout -b tag_$t svn/tags/$t ; done ; | |
| git push -f --set-upstream origin --all | |
| git push -f --set-upstream origin master | |
| # Updates later | |
| git svn fetch | |
| git rebase svn/trunk | |
| git push origin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment