Skip to content

Instantly share code, notes, and snippets.

@pivotal-casebook
Created September 14, 2012 15:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pivotal-casebook/3722584 to your computer and use it in GitHub Desktop.
Save pivotal-casebook/3722584 to your computer and use it in GitHub Desktop.
A shell script which outputs all git branches on origin, sorted by the most recent commit, and shows authors of those commits
metropolitan:casebook2 (master) $ script/show-branch-info
Pruning origin
URL: git@github.com:casebook/casebook2.git
* [pruned] origin/old_branch_1
* [pruned] origin/old_branch_2
2012-09-14 11:09:29 -0400 12 minutes ago John Doe origin/master
2012-09-14 11:09:29 -0400 12 minutes ago John Doe origin/HEAD
2012-09-14 09:48:47 -0400 2 hours ago Jane Doe origin/topic_branch_1
2012-09-14 09:48:14 -0400 2 hours ago Jimmy Doe origin/production_branch
2012-09-13 18:36:23 -0400 17 hours ago Jack Doe origin/topic_branch_2
If you're unable to remove a branch, it may already be gone from the remote. Try git remote prune origin (git remote prune --dry-run origin) to see what remote branch references will be deleted
metropolitan:casebook2 (master) $
#!/bin/sh
git remote prune origin
for k in `git branch -r|awk '{print $1}'`;do echo `git show --pretty=format:"%Cgreen%ci %Cblue%cr %Cred%cn %Creset" $k|head -n 1`\\t$k;done|sort -r
echo "If you're unable to remove a branch, it may already be gone from the remote. Try git remote prune origin (git remote prune --dry-run origin) to see what remote branch references will be deleted"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment