Skip to content

Instantly share code, notes, and snippets.

@klausbayrhammer
Created October 10, 2014 12:52
Show Gist options
  • Save klausbayrhammer/734ca98f5a1b10553eed to your computer and use it in GitHub Desktop.
Save klausbayrhammer/734ca98f5a1b10553eed to your computer and use it in GitHub Desktop.
cherry-pick a commit to multiple branches
#!/bin/bash
function merge {
git pull --rebase
git cherry-pick -x $1
git status
echo "Commit? (y/n):"
read XN
if [ "$XN" = "y" ]; then
echo "Committing"
git push origin
else
echo "Abort!!"
exit
fi;
}
if [ ! -n "$1" ]; then
echo "Usage: cherrypick.sh <hash> [<branch1> <branch2> <branch3> ...]"
echo
echo "e.g. cherrypick.sh fb5cfe1cf2165abee 1.0.0 1.1.0 1.2.0"
exit
fi
if [ ! -n "$2" ]; then
echo "cherry-picking to current branch"
merge $1
else
for arg in ${@:2}
do
git checkout $arg
merge $1
done
fi
@Delfic
Copy link

Delfic commented Jul 2, 2018

It's in the code: Usage: cherrypick.sh <hash> [<branch1> <branch2> <branch3> ...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment