2

I have a garbage of feature branch in central repository apart from master. My master is up to date. Now, I want to know the list of branches that are lagging behind my master branch. I know individual branch selection in github/bitbucket has a graphical view. But, here I have 50 to 60 feature branches to compare. Few of them are ahead of master, few are up to date with master, few are behind master. How can I pin the braches list to a individual files ?

Note: I am using bitbucket

Thanks you in advance.

LVR
  • 21
  • 1

2 Answers2

2

A little bit of hacking and googling (stackoverflowing, rather) and voilà! - a working bash script that does exactly what you want: creates three files with branches of each category (behind, up-to-date or ahead of master).

NB! There's a pull going on, so stash your changes.

git checkout master    
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done #set tracking of all remote branches
git fetch --all # fetch all remote branches to the local repository
git pull --all # update all local branches
for BRANCH in `git branch --list | sed 's/\*//g'`
do
    COMMITS_AHEAD_OF_MASTER=`git log master..$BRANCH`
    if [ -z "$COMMITS_AHEAD_OF_MASTER" ]
    then
        COMMITS_BEHIND_MASTER=`git log $BRANCH..master`
        if [ -z "$COMMITS_BEHIND_MASTER" ]
        then
            echo $BRANCH >> up_to_date.txt
        else
            echo $BRANCH >> behind.txt
        fi
    else
        echo $BRANCH >> ahead.txt
    fi
done
BVengerov
  • 2,947
  • 1
  • 18
  • 32
0

In the repository page in BitBucket you have a 'Branches' tab in the left-side navigation pane. Navigation page

Click on it and you'll get all the branches listed including the ahead/behind column for each branch enter image description here

yorammi
  • 6,272
  • 1
  • 28
  • 34