Created
February 16, 2021 10:15
-
-
Save th0rgall/74c683c7171fc1b91bd1f688e2d8d9c7 to your computer and use it in GitHub Desktop.
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
# git branch behind & ahead - a shell function | |
# inspired on https://stackoverflow.com/questions/20433867/git-ahead-behind-info-between-master-and-branch | |
# usage: gitba branchA...branchB | |
gitba () { | |
echo "$(cut -d '.' -f 4 <<<"$1") is compared to $(cut -d '.' -f 1 <<<"$1")" | |
REVLIST="$(git rev-list --left-right --count $1)" | |
echo $(cut -f 1 <<<"$REVLIST" | cut -f 1) commits behind. | |
echo $(cut -f 2 <<<"$REVLIST" | cut -f 2) commits ahead. | |
} | |
# Example output: | |
# feature/custom-footer is compared to main | |
# 200 commits behind. | |
# 1 commits ahead. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment