Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active December 9, 2016 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/60b49a90e7bbc3c246ea65c78cda87ee to your computer and use it in GitHub Desktop.
Save westonruter/60b49a90e7bbc3c246ea65c78cda87ee to your computer and use it in GitHub Desktop.
#!/bin/bash
# Update Git and SVN repos checked out in the same directory.
#
# Pass a branch name like 4.6 as the sole argument to checkout that branch. Otherwise, master/trunk is checked out.
set -ex
cd "$(dirname $0)"
git fetch origin --tags
git_branch=master
svn_path='^/trunk'
if [ ! -z "$1" ] && [ "$1" != 'master' ] && [ "$1" != 'trunk' ]; then
git_branch=$1
svn_path="^/branches/$1"
fi
git stash save
svn switch --force $svn_path
git checkout -f $git_branch
git reset --hard origin/$git_branch
svn up --force --accept=theirs-full
set +x
echo
echo "## svn status"
svn status | grep -Ev '^\?'
echo
echo "## git status"
git status -uno
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment