Skip to content

Instantly share code, notes, and snippets.

@ytnobody
Created Nov 1, 2018
Embed
What would you like to do?
キーワードでcommit logを引っ掛けてきて、宛先のbranchにcherry-pickするための中間ブランチをつくる、野蛮な工具
#!/bin/sh
help () {
cat <<EOF
Usage:
git-bar [keyword] [Dest Branch]
EOF
exit;
}
keyword=$1; shift
DST_BRANCH=$1; shift
MEMOFILE=$HOME/.git-bar
if [ -z $keyword ] || [ -z $DST_BRANCH ] ; then
help;
fi
echo $keyword" ---> "$DST_BRANCH
WORK_BRANCH="work/"$keyword
BASE_BRANCH=`git branch | grep '*' | awk '{print($2);}'`
git checkout $DST_BRANCH &&
git pull &&
git branch $WORK_BRANCH
git checkout $BASE_BRANCH &&
git log --date-order --reverse --pretty=format:"%H | %s" |
grep "| "$keyword |
awk '{print($1);}' > $MEMOFILE
git checkout $WORK_BRANCH &&
cat $MEMOFILE |
awk '{print("git cherry-pick "$1);}' |
sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment