Skip to content

Instantly share code, notes, and snippets.

@amercier
Last active December 29, 2015 17:19
Show Gist options
  • Save amercier/7703862 to your computer and use it in GitHub Desktop.
Save amercier/7703862 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# ==============================================================================
# svn-to-git.sh - Migrate a SVN repository to Git
# ==============================================================================
echo "==============================="
echo "Migrate a SVN repository to Git"
echo "==============================="
echo
read -p "SVN source repository (ex: http://my-svn-server/my-project): "
SRC="$REPLY"
read -p "Destination repository (ex: http://me@my-svn-server/my-project.git: "
DEST="$REPLY"
NAME="$(echo $DEST | sed -E 's/^.*\/([^\/]+)\.git$/\1/')";
function ask {
read -r -p "$1"
if [[ $REPLY =~ ^[Yy]$ ]]
then
return 1;
else
echo "$2"
exit
fi
}
echo
echo "This will:"
echo " 1. Create a local GIT-SVN repository in `pwd`/$NAME-tmp"
echo " 2. Migrate SVN repository $PWD into this GIT-SVN repository"
echo " 3. Copy the local GIT-SVN repository into a clean Git repository in `pwd`/$NAME"
echo " 4. Export the local Git repository to $DEST"
echo
ask "Continue? [y/N] " "Migration aborted"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment