Created
January 31, 2020 18:04
-
-
Save tomchapin/dc0d53cbe7e8246955895017163faf48 to your computer and use it in GitHub Desktop.
This git command lists all branches (local and remote) and orders them by their most recent commit date. Also displays the commit author.
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 | |
# -------------------------------------------------------------------------- | |
# Git Recent with Details (by Tom Chapin - https://gist.github.com/tomchapin/dc0d53cbe7e8246955895017163faf48) | |
# ------------------------------------------------------------------------- | |
# One-liner command by estani from this Stack Overflow thread: | |
# https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit | |
# -------------------------------------------------------------------------- | |
# This git command lists all branches (local and remote) and orders them by | |
# their most recent commit date. Also displays the commit author. | |
# -------------------------------------------------------------------------- | |
# Installation: | |
# Copy this script as a file named "git-recent-details" somewhere in | |
# your path (For example: /usr/local/bin/git-recent-details), and then | |
# run "chmod +x git-recent-details" to give it execution permissions. | |
# -------------------------------------------------------------------------- | |
# Usage: | |
# From inside your git repo, type "git recent-details" | |
# -------------------------------------------------------------------------- | |
set -euo pipefail | |
for ref in $(git for-each-ref --sort=-committerdate --format="%(refname)" refs/heads/ refs/remotes ); do git log -n1 $ref --pretty=format:"%Cgreen%cr%Creset %C(yellow)%d%Creset %C(bold blue)<%an>%Creset%n" | cat ; done | awk '! a[$0]++' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment