Skip to content

Instantly share code, notes, and snippets.

@schwern
Created February 27, 2010 02:44
Show Gist options
  • Save schwern/316423 to your computer and use it in GitHub Desktop.
Save schwern/316423 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Find the child of the current (or supplied) commit.
REV=$1
if [ x$REV == x ]; then
REV="HEAD"
fi
HASH=$(git-rev-parse $REV)
NUM=$2
if [ x$NUM == x ]; then
NUM=1
fi
git rev-list --all --parents | grep " $HASH" | sed -n "${NUM}s/\([^ ]*\) .*$/\\1/p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment