Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Created July 1, 2016 20:51
Show Gist options
  • Save IanVaughan/b4efae345a7bd8cfac1c27b0cbc1de69 to your computer and use it in GitHub Desktop.
Save IanVaughan/b4efae345a7bd8cfac1c27b0cbc1de69 to your computer and use it in GitHub Desktop.
Bash script to show branches merged into a branch
#!/bin/sh
# Bash script to show branches merged into a branch
# Place within your $PATH
# Usage : staging-branches
# Finds all merged branches since master and lists them out
master_sha=$(git show-ref origin/master -s)
merged_branches=$(git log $master_sha.. --format="%s" | grep Merge)
printf '%s\n' "${merged_branches[@]}" | cut -d " " -f3- | cut -d ' ' -f 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment