Created
September 16, 2019 16:45
-
-
Save carlosmcevilly/271f6a451bec92256e0b8ef98523c3d8 to your computer and use it in GitHub Desktop.
Check whether the current branch has <git hash> as an ancestor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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