Skip to content

Instantly share code, notes, and snippets.

@dlanner
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save dlanner/8790027 to your computer and use it in GitHub Desktop.

Select an option

Save dlanner/8790027 to your computer and use it in GitHub Desktop.
Bash script to help switch between different revision control branches in Vagrant
#!/usr/bin/env bash
# Usage: ./vagrant_switch_branch 1.0
# export APP_ROOT=/path/to/my_app
# export CURRENT_BRANCH=$APP_ROOT/current_branch
if [ ! -n "$APP_ROOT" ]; then
echo "Error: APP_ROOT is not defined"
exit 1
elif [ ! -n "$CURRENT_BRANCH" ]; then
echo "Error: CURRENT_BRANCH is not defined"
exit 1
else
BRANCH=$1
if [ ! -d $APP_ROOT/$BRANCH ]; then
echo "Error: $APP_ROOT/$BRANCH does not exist"
exit 1
else
if [ -L $CURRENT_BRANCH ]; then
rm $CURRENT_BRANCH
fi
ln -s $APP_ROOT/$BRANCH $CURRENT_BRANCH
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment