Skip to content

Instantly share code, notes, and snippets.

@JeffCarpenter
Created May 12, 2017 22:31
Show Gist options
  • Save JeffCarpenter/61c4f20c53a61137738aaffe47a46130 to your computer and use it in GitHub Desktop.
Save JeffCarpenter/61c4f20c53a61137738aaffe47a46130 to your computer and use it in GitHub Desktop.
List branches whose head was committed prior to a given date
#!/bin/bash
function git-old-heads {
git show-ref --heads | grep -E "$(git rev-list --all --before="$1" | cut -d' ' -f2 | xargs | sed -e 's/ /|/g')"
}
function filter-branch-names {
cut -f2 -d' ' | sed -e 's|refs/heads/||g'
}
git-old-heads "$1" | filter-branch-names
# eg. git-old-branchs "2 months ago"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment