Created
September 28, 2011 00:38
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
.