Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It seems there is no git built-in support for what I want, but with some git plumbing I got the results I was looking for, inspired by <a href="https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git">Finding a branch point with Git?</a>.</p> <p>Let me know if these assumptions are not correct...</p> <ul> <li>A branch whose head matches its branch point from <code>origin/master</code> (ie. has no commits) should be an empty branch, indicating the intention of doing work.</li> <li>A branch whose best merge point with <code>origin/master</code> matches its head is already fully merged, and can be ignored.</li> <li>Any other case should be a branch with unmerged changes.</li> </ul> <p>Example script that prints the category for all remote branches; if Bob ran this it would tell him <code>refs/remotes/origin/branch1: new branch without any commits</code>:</p> <pre class="lang-sh prettyprint-override"><code>#! /usr/bin/env bash # check branches created from and merged to this branch MASTER=refs/remotes/origin/master # for each remote branch... for BRANCH in $(git for-each-ref --format='%(refname)' refs/remotes/); do # ...except the $MASTER branch and the current HEAD [[ $BRANCH == $MASTER || $BRANCH =~ /HEAD$ ]] &amp;&amp; continue # get the hash for the head of the branch BRANCH_HEAD=$(git show-ref --head --hash $BRANCH) # returns the first shared commit among $MASTER and $BRANCH commits BRANCH_POINT=$(fgrep -m 1 -f &lt;(git rev-list --first-parent $BRANCH) \ &lt;(git rev-list --first-parent $MASTER)) # find the best merge point BRANCH_MERGE=$(git merge-base $MASTER $BRANCH) # determine the type of branch if [[ $BRANCH_POINT == $BRANCH_HEAD ]]; then echo "$BRANCH: new branch without any commits" elif [[ $BRANCH_MERGE == $BRANCH_HEAD ]]; then echo "$BRANCH: fully merged into $MASTER" else echo "$BRANCH: branch with unmerged changes" fi done </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload