What is the 50/72 rule?
50/72 rule is a commonly accepted best practice for formatting commit messages in Git. This is also considerable for other version control systems, as it is absolutely not tied to Git. It was originally "invented" and promoted by the Linux Kernel team, and gained universal popularity later.
Low standard commits ruin traceability
Concise, straightforward messages can save you a ton of time in case you need to dig deep into the project history. Programmers tend to write one-word commit messages that do not tell much later in time and make traceability practically impossible.
Other times those messages are more like long descriptions that are hard to follow. Applying this rule can help to overcome these problems and force writing well-formatted messages with the correct levels of details.
The rules of the game
The rule is simple:
- Summary: maximum 50 characters long first line
- Then a blank line
- Description: arbitrary number of maximum 72 characters long lines, at most one blank line between them (This part is optional. For trivial commits you may not want to write any details at all.)
Why 50 and why 72?
50 characters is the average length of the commit messages in the Linux Kernel codebase
Well, these are most definitely not random values, but the result of analyzing the Linux Kernel codebase for ideal values. Plus, they work very well in the popular development tools (think of text wrapping in the console and so).
The Jira app of choice for controlling commits
50/72 can be easily enforced using the Jira app called Better Commit Policy. The idea is that the app requires each commit message pushed to the repository to match a regular expression that enforces the requirements above, otherwise the push is rejected.
To create a commit policy that makes developers comply with the 50/72 rule, just do this:
- Add a new "Commit message must match a pattern" condition to a new or existing commit policy.
- Set the following regular expression:
- Enjoy the nicely formatted future commit messages!
Configuring Better Commit Policy to help your team follow the Git 50/72 rule is just one way the app can make your repository well maintained and the code changes easy to understand for a reviewer. As software penetrates almost every industry now, in some cases it's also an imperative to have an audit-proof log of code changes. In regulated industries - like aviation or medical tech -, stricter rules need to be applied, as the actions made or supported by your software has far-reaching consequences.
Be it for the sake of an internal code review or for complying with authorities' requests, it's our mutual interest to make source code changes always traceable in Git or in any other version control system.