garysimpson.dev
Mobile development with swift and flutter

List Git Commits by Hash and Comment

August 05, 2025 at 3:30PM

Super simple way to list the last 10 commits in the following ways.

Here is a hash only approach:

  • git log --pretty=format:"%h" -n 10

Here is a with char string:

  • 64 chars: git log --pretty=format:"%h (%<(64,trunc)%s)" -n 10
  • 96 chars: git log --pretty=format:"%h (%<(96,trunc)%s)" -n 10
  • 96 chars: git log --pretty=format:"%h %<(96,trunc)%s" -n 10

Happy Coding ;-)