Search code examples
gitrevision-history

How can I filter git log to show a list of specific revisions/commits?


Let's say I have several commits, and I know their revision IDs:

  • aaaaaa
  • bbbbbb
  • cccccc
  • dddddd

These commits are not consecutive, and aren't related to each other from git's perspective.

How can I output information about all of these commits in a list with a single command?


Solution

  • Simply use git show:

    git show aaaaaaa bbbbbb cccccc dddddd

    You can use the --pretty=format:... to change the output and display each information you want of each commit on one line. Also --no-patch (or -s) to avoid displaying patch.

    git show --no-patch --pretty='format:%h %aN %ad %s' aaaaaaa bbbbbb cccccc dddddd

    Documentation: https://git-scm.com/docs/git-show