Skip to content

Instantly share code, notes, and snippets.

@benhamill
Created September 28, 2011 00:38
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 benhamill/1246677 to your computer and use it in GitHub Desktop.
Save benhamill/1246677 to your computer and use it in GitHub Desktop.
Make this executable and it will list for you the remote branches that haven't been merged into the "develop" branch. You can, of course, grep for a different branch name (master?) or change the || to && to get remote branches that ARE merged in.
#! /bin/sh
if [[ -z $1 ]]; then
echo "You must provide a branch name against which to test merging."
exit 1
fi
gather_branches() {
for remote in `git for-each-ref --format='%(refname)' 'refs/remotes/'`
do
git branch --contains $remote | grep -q $1
if [[ $? ]]; then
branch_name=`echo $remote | sed -e's/refs\/remotes\///'`
fi
commit_time_output=`git log --format=format:'%ad,%cn,%at' $branch_name | head -n1`
echo $branch_name$','$commit_time_output
done
}
gather_branches $1 | sort -t',' -k4
@benhamill
Copy link
Author

Updated this to accept a command-line argument for which branch to compare against and then do some sorting and prettifying of output. Usage like this: unmerged-branches develop > look_into_these.csv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment