Skip to content

add flag --first-parent only display first parent of merge commits #137

Open

Description

@vincent-chtln

In a typical GitHub workflow, there is a main with short-lived feature or bugfix branches that are merged to the main branch.

git log has a --first-parent option that allow to hide all the commits in the temporary branches and only display the merge commits of the main branch. It can greatly simplify the reading the git history, since only the non-merged branches appear (either long-lived branches or not-yet-merged branches).

I believe GitLab is doing the same for their git log, hiding commits in forks and in temporary branches.

Here's a screenshot the Git Graph extension for Visual Studio Code that implements this option pretty nicely (blue is main, pink is a release branch):

  • without --first-parent on the left
  • without --first-parent on the right

(note: the colors between left and right don't necessary refer to the same branches)

Image Image

Activity

  1. peso commented on Jan 16, 2026

    @peso
    Collaborator

    This is a great feature, although the name is somewhat misleading. Maybe --follow-first-parent-only .. hm, a little long. A little shorter: --hide-merged-branches. Suggestions are welcome

    There is a backside, that should be mentioned somewhere. if all branches have been merged, it looks as if none ever happened. Do you want this to apply to all branches, or only the one you pick (eg. main)?

  2. pinage404 commented on Jan 17, 2026

    @pinage404

    I suggest --no-merged like git branch --no-merged

  3. vincent-chtln commented on Jan 19, 2026

    @vincent-chtln
    Author

    --first-parent was mentioned for behavior reference, but I agree this is not a great name.

    To me the way git-log or Git Graph extension displays it is perfect.

    To address your concern, I believe git-graph should keep the specific icon for merge commits even when hiding merged branch. This way, users would still be able to differentiate different types of commits (which Git Graph extension doesn't have unfortunately) and have information about where merges happen (at least the last one that impacts their branch).

    As a side note, there are some comments where this option doesn't apply to all git workflow because people sometimes have weird branch management. So it's probably a good idea to still mention --first-parent in the help or documentation, unless of course if you want to come up with a different implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions