Skip to content

Instantly share code, notes, and snippets.

@carlosmcevilly
Created September 16, 2019 16:45
Show Gist options
  • Save carlosmcevilly/271f6a451bec92256e0b8ef98523c3d8 to your computer and use it in GitHub Desktop.
Save carlosmcevilly/271f6a451bec92256e0b8ef98523c3d8 to your computer and use it in GitHub Desktop.
Check whether the current branch has <git hash> as an ancestor
#!/bin/bash
export hash=$1
if [[ "$hash" == '' ]]; then
echo usage: $0 '<git hash>'
exit -1
fi
if git merge-base --is-ancestor $hash HEAD 2> /dev/null; then
echo $hash is an ancestor of the current branch
else
echo $hash is not an ancestor of the current branch
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment