Skip to content

Instantly share code, notes, and snippets.

@andypotanin
Last active December 20, 2015 06:19
Show Gist options
  • Save andypotanin/6085356 to your computer and use it in GitHub Desktop.
Save andypotanin/6085356 to your computer and use it in GitHub Desktop.
Bash script for automating migrating SVN repository tags to a Git repository, maintaining tags.
# Bash script for automating migrating SVN repository tags to a Git repository, maintaining tags.
#
# Checkout SVN into a temporary directory, e.g:
# svn checkout http://plugins.svn.wordpress.org/wp-invoice/
# Setup the target Git repository
# git clone https://github.com/UsabilityDynamics/wp-invoice.git /products/wp-invoice
# git push -u origin master
# Directory with SVN version tags
TAGS=/products/wp-invoice-temp/tags/*
# Directory with Git repository
TARGET=/products/wp-invoice
for directory in $TAGS
do
# Set directory name of current directory
version=$(basename $directory)
echo "Processing $version version."
# Move into target Git repository
cd $TARGET
# Remove all files recursively
rm -rf *
# Remove all stuff from git
git rm . -r
# Recursively copy a tag into working Git repository
cp -r "$directory/" $TARGET
# Remove svn references and other junk files
rm -rf .svn
rm -rf .DS_Store
# Add the new copied files to git
git add .
# Commit this version
git commit -m "Committing WordPress.org $version version."
# Push current release
git push
# Set tag for this version
git tag -a $version -m "Marking WordPress.org release $version."
# Push all tags
git push --tags
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment