Skip to content

Instantly share code, notes, and snippets.

@philz
Created August 30, 2013 20:11
Show Gist options
  • Save philz/6393825 to your computer and use it in GitHub Desktop.
Save philz/6393825 to your computer and use it in GitHub Desktop.
git-above
# License: Public Domain
#
# Usage: git-above [ref]
#
# ref defaults to "origin/master" if not specified.
#
# Returns the commit directly after that commit. Useful for pushing
# the "bottom" of your stack of changes above master.
#
# Is there a better way?
#
$type git-above
git-above is a function
git-above ()
{
x=${1:-origin/master};
git-rev-list --ancestry-path "$x"..HEAD --reverse | head -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment