Skip to content

Instantly share code, notes, and snippets.

@yszheda
Last active December 9, 2015 03:36
Show Gist options
  • Save yszheda/fd1ee07fda5c11c9c08b to your computer and use it in GitHub Desktop.
Save yszheda/fd1ee07fda5c11c9c08b to your computer and use it in GitHub Desktop.
sync the specified git commit to another git-svn/svn branch
#!/bin/bash
if [ $1 == "-h" ]; then
echo "Usage: "
echo "$(basename $0) <git commit SHA1>"
exit 0
fi
SHA1=$1
REPO_DIR=""
PATCH_DIR=""
SOURCE_BRANCH=dev
DEST_BRANCH=release
cd ${REPO_DIR}
git stash
git checkout ${SOURCE_BRANCH}
patch_file=`git format-patch -1 ${SHA1} -o ${PATCH_DIR}`
git checkout ${DEST_BRANCH}
git svn rebase
# apply patch for any svn repo
# patch -p1 -i ${patch_file}
# in git-svn repo, use `git am` instead
git am ${patch_file}
# check the commit manually
# tig
git log
git svn dcommit
git checkout ${SOURCE_BRANCH}
git stash pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment