Last active
December 9, 2015 03:36
-
-
Save yszheda/fd1ee07fda5c11c9c08b to your computer and use it in GitHub Desktop.
sync the specified git commit to another git-svn/svn branch
This file contains hidden or 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 | |
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