Skip to content

Instantly share code, notes, and snippets.

@haileys
Created January 8, 2014 04:04
Show Gist options
  • Save haileys/8311607 to your computer and use it in GitHub Desktop.
Save haileys/8311607 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# = 0 ]; then
echo "Usage: git pr-for <commit>" >&2
exit 1
fi
SHA="$(git log "$1"..master --ancestry-path --merges --reverse --oneline | grep 'Merge pull request' | head -1 | cut -d' ' -f1)"
if [ -n "$SHA" ]; then
git show "$SHA"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment