Skip to content

Instantly share code, notes, and snippets.

@epishkin
Created November 14, 2014 16:42
Show Gist options
  • Save epishkin/4ec2e816c392c3dc22a3 to your computer and use it in GitHub Desktop.
Save epishkin/4ec2e816c392c3dc22a3 to your computer and use it in GitHub Desktop.
show remote branches of a git repo sorted by date
remove_head() {
for BRANCH in $ALL_BRANCHES;
do
if [ "$BRANCH" = "->" ] || [ "$BRANCH" = "origin/HEAD" ]; then
continue
fi
echo $BRANCH
done | sort -u
}
ALL_BRANCHES=`git branch -r | sed s/^..//`
BRANCHES=`remove_head $ALL_BRANCHES`
printf "\n %-50s \t %-30s \t %s\n" "DATE" "BRANCH" "SHA & Commit message"
for BRANCH in $BRANCHES;
do
if [ "$BRANCH" = "->" ] || [ "$BRANCH" = "origin/HEAD" ]; then
continue
fi
BRANCH_DATE=`git log -1 --pretty=format:"%Cgreen%ci %Creset%cr%Creset" "$BRANCH"`
BRANCH_LAST_COMMIT=`git log -1 --pretty=format:"%h [%an] %s%d" "$BRANCH" | cut -c 1-105`
BRANCH_SHORT=`echo "$BRANCH" | cut -c 1-35`
printf "\n %-50s \t %-30s \t %s" "$BRANCH_DATE" "$BRANCH_SHORT" "$BRANCH_LAST_COMMIT"
done|sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment