Last active
December 9, 2016 22:28
-
-
Save westonruter/60b49a90e7bbc3c246ea65c78cda87ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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