Skip to content

Instantly share code, notes, and snippets.

@deeGraYve
Forked from jsanders/README.md
Created October 30, 2013 17:00
Show Gist options
  • Select an option

  • Save deeGraYve/7236185 to your computer and use it in GitHub Desktop.

Select an option

Save deeGraYve/7236185 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
branch=remotes/$1
function reverted_commits () {
git log | grep 'This reverts commit' | awk '{ print substr($4, 1, 7) }' | tr -d '.,'
}
function branches () {
git branch -av | grep "$1" | sed -e "s|$1/||" | awk '{ print $2 " " $1 }'
}
branches "$branch" | sort > branches.tmp
reverted_commits | sort > reverts.tmp
# Remove branches that have been reverted
join -v1 branches.tmp reverts.tmp > candidates.tmp
git log --format='%h' "$branch"/master | sort | join candidates.tmp -
rm branches.tmp reverts.tmp candidates.tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment