4

Git hosting web services like Bitbucket Server and GitHub provide a branch view that shows whether branches are ahead or behind master:

github branches

This is great for finding remote branches which have been merged and can be deleted.

Can I see whether remote branches are behind or ahead with magit?

I found issue 1550 but that just shows the age and author, not the number of commits. L L gives:

magit branches

2
  • It does show it for me in the refs buffer, even though I don't have any specific settings for this. Maybe I'm using an older version than the one you have? In my version the tracked branch appears inside brackets and whenever there's a difference in commits between remote and local it shows the numbers.
    – wvxvw
    Commented Feb 16, 2017 at 12:01
  • Oh, but I think you would need to have local branch tracking cons_function for example, to see the difference between it and the remote, otherwise there's really nothing to show (Git doesn't know what to compare it to).
    – wvxvw
    Commented Feb 16, 2017 at 12:04

1 Answer 1

5

I'm not aware of a place where this is available in a unified view. As @wvxvw comments, the refs buffer will show ahead/behind counts against the upstream branch but not an arbitrary branch.

The closest the refs buffer curently gets is showing the number of commits each branch is ahead of a selected branch or revision. By default, things are compared to HEAD, but you can use C-u y to select another branch. Then, in the refs buffer, C-y b will show the ahead counts for each branch. If you press tab on a line, it will expand to show the commits (with an indication of whether each commit has been applied to the selected branch).

You could fairly easily produce the GitHub-like view by iterating over the branches and calling (magit-rev-diff-count "master" <branch>).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.