TIL: Editing Git Commit Messages after Gitlint commit-msg Hook Failure

Posted by Michael Knott on Wed 08 May 2024

Editing Git Commit Messages after Gitlint commit-msg Hook Failure

In the course of working on a project that utilizes Gitlint with pre-commit, I encountered a situation where the Gitlint commit-msg hook would fail due to a commit message not meeting the required format. Initially, it seemed as though I had lost my previous commit message, which meant I had to waste time retyping the message.

However, I discovered a handy command that solves the issue thanks to this issue thread in the Gitlint GitHub repository.

git commit --edit --file .git/COMMIT_EDITMSG

This command opens up the text editor with the previous commit message already populated, allowing for easy editing and saving a lot of time.

tags: TIL, Python, gitlint