Skip to content

Instantly share code, notes, and snippets.

@mpdaugherty
Created October 6, 2023 13:25
Show Gist options
  • Save mpdaugherty/3de536a58a447281bd22703dfa0beae0 to your computer and use it in GitHub Desktop.
Save mpdaugherty/3de536a58a447281bd22703dfa0beae0 to your computer and use it in GitHub Desktop.
View local git branches ahead/behind of main
#!/bin/bash
for branch in $(git branch | sed 's/* //'); do
ahead=$(git log --oneline main..$branch | wc -l | tr -d ' ');
behind=$(git log --oneline $branch..main | wc -l | tr -d ' ');
printf "+%5s, -%5s : %s\n" "$ahead" "$behind" "$branch";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment