DEV Community

Discussion on: Using Aliases to Speed Up Your Git Workflow

Collapse
 
drhyde profile image
David Cantrell • Edited

The one that I use a lot (I've got it as a shell script rather than as an alias or function) is ...

#!/bin/bash
SOURCE=$1
NUM=$2

if [ "$SOURCE" == "-h" -o "$SOURCE" == "" ]; then
    echo
    echo Usage: pick-many-cherries SOURCE COUNT
    echo
    echo Cherry-pick the last COUNT commits from SOURCE in chronological order.
    echo There is NO ERROR CHECKING.
    echo
    exit
fi

for i in {% raw %}`git log $SOURCE |grep ^commit |head -$NUM |awk '{print $2}' |tac`{% endraw %}; do git cherry-pick $i;done