Last active
October 20, 2016 18:12
-
-
Save donatj/7ae9246c964189a4c2f9 to your computer and use it in GitHub Desktop.
Easily cherry pick one or more commits to a new 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/zsh | |
set -e | |
if [ $# -lt 3 ] | |
then | |
echo "Not Enough Arguments" | |
return 1 | |
fi | |
START_BRANCH=`git rev-parse --abbrev-ref HEAD` | |
BASE="$1" | |
shift | |
NEW="$1" | |
shift | |
git stash -u | |
git checkout "$BASE" | |
git checkout -b "$NEW" | |
for var in "$@" | |
do | |
git cherry-pick "$var" | |
done | |
git checkout "$START_BRANCH" | |
git stash pop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment