Created
January 2, 2016 00:15
-
-
Save manishpathak99/fdce599527ed1097d672 to your computer and use it in GitHub Desktop.
This script migrated the svn repo to git repo.(Script to copy SVN history to GIT history).
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
usage () | |
{ | |
echo 'This script is used to migrate the SVN repo to GIT repo' | |
echo 'Please provide the parameters as below' | |
echo 'Usage : Script <SVN_REPO_URL> <GIT_REPO_URL>' | |
echo 'Usage : Script http://10.42.0.54/mysvn/myrepo/SocialShare git@github.com:manishpathak99/socialshare.git' | |
exit | |
} | |
if [ "$#" -ne 2 ] | |
then | |
usage | |
fi | |
mkdir migrated_code | |
cd migrated_code | |
git svn init $1 --stdlayout --prefix=svn/ | |
echo '****************************FETCHING SVN $1****************************************' | |
git svn fetch | |
for branch in `git branch -r | grep "branches/" | sed 's/ branches\///'`; do | |
git branch $branch refs/remotes/$branch | |
done | |
for tag in `git branch -r | grep "tags/" | sed 's/ tags\///'`; do | |
git tag -a -m"Converting SVN tags" $tag refs/remotes/$tag | |
done | |
git remote add origin $2 | |
echo '****************************PUSHING GIT BRANCH to $2****************************************' | |
git push -u origin --all # pushes up the repo and its refs for the first time | |
echo '****************************PUSHING GIT TAG to $2****************************************' | |
git push -u origin --tag # pushes up the repo and its refs for the first time | |
echo 'DONE' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment