lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

support `prepare-commit-msg` Git hook

Open rznn7 opened this issue 3 months ago • 1 comments

Is your feature request related to a problem? Please describe.

The prepare-commit-msg Git hook is currently being ignored when committing through lazygit, both in the commit popup and editor mode. This prevents automatic commit message preparation workflows from functioning as expected.

Describe the solution you'd like

I'd like lazygit to execute the prepare-commit-msg hook before presenting the commit message input interface (both in the commit popup and editor mode). This would align lazygit's behavior with standard Git workflow, where the hook runs before the user enters their commit message, allowing the hook to pre-populate or modify the message template.

Describe alternatives you've considered

A custom command might work as a workaround? but this feels like it should be the default behavior to maintain consistency with Git's standard hook execution flow.

Additional context

My specific use case involves a prepare-commit-msg hook that automatically prepends ticket numbers to commit messages based on the current branch name (e.g., extracting PROJ-123 from a branch like feature/PROJ-123-add-new-feature).

I'd be happy to submit a PR to implement this feature if needed 🙂

rznn7 avatar Oct 28 '25 15:10 rznn7

I second this. Just yesterday I tied into the prepare-commit-msg for populating local LLM-generated commit messages. Which works great, but not in LazyGit using c flow.

I did add a custom command as a workaround that opens nvim for editing the generated message, but I would much prefer c trigger the hook as expected to keep the native LG commit UI.

No shade, though. LazyGit is amazing.

dustinc avatar Nov 05 '25 04:11 dustinc