Skip to content

Instantly share code, notes, and snippets.

@dagezi
Last active December 13, 2019 16:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagezi/bf91c9e7d5c5307c5b47ebd674328c7c to your computer and use it in GitHub Desktop.
Save dagezi/bf91c9e7d5c5307c5b47ebd674328c7c to your computer and use it in GitHub Desktop.
The small shell script to show git branches in recently-used order.
#!/bin/sh -e
function show_latest_branches () {
git branch | \
sed 's/[* ]//g; s/.*/printf "& "; git show --format="%at" -s &/'| \
sh | \
sort -k2nr
}
case "$1" in
-v) # verbose;
show_latest_branches
;;
*)
show_latest_branches | cut -d ' ' -f 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment