Skip to content

Instantly share code, notes, and snippets.

@dan-lind
Forked from SarasArya/cherry-pick-by-author.sh
Created October 1, 2020 03:47
Show Gist options
  • Save dan-lind/4815864018234c81c4b0758312643746 to your computer and use it in GitHub Desktop.
Save dan-lind/4815864018234c81c4b0758312643746 to your computer and use it in GitHub Desktop.
This gist lists the cherry pick by author and stores in a file and apply it on a branch
#!/usr/bin/env bash
if [ -z ${1} ]
then
echo "Enter first argument which is author name";
exit
fi
if [ -z {$2} ]
then
echo "enter second argument which is in which branch you want these commits to go"
exit
fi
echo "Cherry picking commit for user ${1} from branch $(git symbolic-ref --short -q HEAD) will put into ${2}" ;
git log --committer="saras.arya@rentomojo.com" --format=format:%H > cherry-pick.txt
git checkout ${2}
for commit in $(cat cherry-pick.txt) ; do
hash=$(echo ${commit} | cut -d$'\t' -f 1)
printf "${hash}\n"
git cherry-pick ${hash}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment