Skip to content

Instantly share code, notes, and snippets.

@manishpathak99
Created January 2, 2016 00:15
Show Gist options
  • Save manishpathak99/fdce599527ed1097d672 to your computer and use it in GitHub Desktop.
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).
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