Last active
June 18, 2018 13:56
-
-
Save mfehr/1217a05b97bc944339dee260331e01fd to your computer and use it in GitHub Desktop.
Show all branches and whether they are up to date on the remote
This file contains hidden or 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 | |
git fetch --quiet | |
message="Does not exist on remote!" | |
all_remote_branches=$(git branch -r) | |
echo -e "\n\e[1m remote\tlocal\tbranch name\e[0m" | |
git branch | while read line ; do | |
output_line="" | |
branch_name=${line//"* "} | |
if [[ $all_remote_branches =~ .*origin\/$branch_name[[:space:]]+.* ]]; then | |
branch_status=$(git rev-list --left-right --count origin/${branch_name}...${branch_name}) | |
output_line=" $branch_status\t" | |
if [[ $branch_status =~ .*0[[:space:]]+0.* ]]; then | |
echo -e "$output_line\e[32m${branch_name}\e[0m" | |
elif [[ $branch_status =~ .*[0-9][[:space:]]+0.* ]]; then | |
echo -e "$output_line\e[33m${branch_name}\e[0m" | |
else | |
echo -e "$output_line\e[31m${branch_name}\e[0m" | |
fi | |
else | |
echo -e " -\t-\t\e[31m${branch_name}\e[0m -> $message" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @floriantschopp