#!/bin/bash # # Copyright (C) 2011, William Trevor King # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # usage: git-unmerged-branches.sh # # List branches with commits not merged into the current branch. # # Inspired by jcromartie's https://gist.github.com/892979/ BRANCH_LIST_OPTS="-a" # compare against all branches #BRANCH_LIST_OPTS="-r" # only compare against remote branches #CURRENT_BRANCH=$(git branch | grep '^\*' | sed 's/\* *//'); BRANCHES=$(git branch $BRANCH_LIST_OPTS | grep -v '^\*\| -> ') for BRANCH in $BRANCHES; do CONTAINS=$(git branch --contains "$BRANCH" | grep '^\*') if [ -z "$CONTAINS" ]; then echo $BRANCH fi done