Sublime Forum

Show only merge commits?

#1

Hi, Is there a way to show only merge commits on a branch? (I am looking for git log --merges command output)

0 Likes

#2

The --merges command line argument to git is an alias for --min-parents=2 , which filters the output to only display commits with at least two parents. To do that in Merge you can use the Search panel, which you can get to via Navigate > Search in the menu (it’s also bound to Ctrl+F on Windows/Linux and Cmd+F on MacOS).

In there you can specify a filter of min-parents: 2 to filter the list in the same fashion:

Unlike in the standard tree, in this case the merge commits don’t display with squares that allow you to collapse/expand them to see their contents because the filter is specifying that only merge commits can appear in the output. To see the contributing commits you can click on the hashes next to parents: in the commit details pane.

0 Likes

#3

Ah, great thanks for the workaround!

Since it’s a supported options and more user friendly name, it might be a good to support this as a menu item?

0 Likes

#4

It is indeed possible to add this to the menu (or the command palette) if you’d like. For example, you can create one or both of the following files in your Merge User package (which you can use by picking Preferences > Browse Packages... from the menu):

Default.sublime-commands

[
    { "caption": "Show Merge Commits", "command": "search","args": {
        "query": "min-parents: 2"
    }},
]

Main.sublime-menu

[
    {
        "id": "repository",
        "children":
        [
            { "caption": "-" },

            { "caption": "Show Merge Commits", "command": "search", "args": {
                "query": "min-parents: 2"
            }},
        ]
    }
]

You can of course adjust the captions or command arguments to suit (or add other similar items if you have a few queries you always run).

1 Like