Skip to content

Instantly share code, notes, and snippets.

@akochepasov
Created September 5, 2025 23:53
Show Gist options
  • Select an option

  • Save akochepasov/57e05fa6e71fd3ae73e47e83681b1b66 to your computer and use it in GitHub Desktop.

Select an option

Save akochepasov/57e05fa6e71fd3ae73e47e83681b1b66 to your computer and use it in GitHub Desktop.
svn2git
# 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