Created
November 11, 2021 15:59
-
-
Save swanandmehta/5fd73d8f09dfeae1512007d92d99ef69 to your computer and use it in GitHub Desktop.
SVN to git migration script
This file contains 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
#!/usr/bin/env sh | |
echo Please provide svn project repo : | |
read svnRepo | |
echo Please provide git project repo : | |
read gitRepo | |
echo Please provide svn project name : | |
read projectName | |
root="${projectName}_root" | |
svnDir="${projectName}_svn" | |
gitDir="${projectName}_git" | |
mkdir -p $root | |
cd $root | |
mkdir -p $svnDir | |
cd $svnDir | |
svn checkout $svnRepo | |
cd $projectName | |
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > ../../users.txt | |
cd ../../ | |
read -p "Press [Enter] key to confirm the users.txt file is updated with valid accounts which are present in git." | |
mkdir -p $gitDir | |
cd $gitDir | |
git svn clone --stdlayout --no-metadata -A ../users.txt $svnRepo | |
cd $projectName | |
for t in $(git for-each-ref --format='%(refname:short)' refs/remotes/tags); do git tag ${t/tags\//} $t && git branch -D -r $t; done | |
for b in $(git for-each-ref --format='%(refname:short)' refs/remotes); do git branch $b refs/remotes/$b && git branch -D -r $b; done | |
git remote add origin $gitRepo | |
read -p "Press [Enter] key to confirm force push branches, tags into git." | |
git push -f --all | |
read -p "Press [Enter] key to quit the program." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment