Which commit has the largest message?

I write and advocate for others to write detailed Git commit messages within the subject body to provide context and information about why the commit was needed, what other options were considered, any consequences or knock-on effects there could be, or even code snippets or pseudo code.

Recently, I was curious to know which commit in a repository has the longest commit message, what code has changed in that commit, and who wrote it.

I was hoping for a command like git shortlog --summary --all (which shows all authors to a codebase and their number of commits), but couldn't find one, so I wrote a script to do it.

It's a bash script that loops over the commits in the repo, calculates the length of each message, sorts them and shows the commit with longest message.

It was an interesting task and shows examples of using various UNIX commands and Linux coreutils, such as find, cut, sort and wc in combination with Git.

The longest in this website's code base is 546 characters, which is fairly small compared to some of my messages in other projects.

What's the longest commit message in the repository you're working in?

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.