COMMIT_GUIDELINES.md
We follow conventional commits as defined here. We (and most major projects) will not merge your PR unless your commit history aligns to these guidelines.
This document explains how to clean up your commit history, squash commits into a single commit if needed, and ensure you adhere to our conventional commit style. We use the following standard prefixes:
Consider a history like this:
9ec71a4 partial fix for issue #22
4a8d2b6 correct typo in logging
a19b75c Merge branch 'main' into feature-branch
3b22d10 update docs again
We want to transform these into a single clean commit or a small number of commits with proper messages. At the end, we want only this:
9ec71a4 fix: partial fix for issue #22
git checkout feature-branch
git fetch origin
git rebase origin/main
git rebase -i HEAD~4
A text editor opens with a list of commits.
pick (the first commit you want to keep) and mark the others as squash or fixup:pick 9ec71a4 partial fix for issue #22
squash 4a8d2b6 correct typo in logging
squash a19b75c Merge branch 'main' into feature-branch
squash 3b22d10 update docs again
pick: Keep the commit as is.squash: Combine this commit with the previous commit and let you edit the commit message.fixup: Combine this commit with the previous commit but use the previous commit’s message.squash. Enter a new commit message that follows our style:feat: add documentation and fix logging
(Detailed description about what was changed and why.)
git add <file1> <file2> ... git rebase --continue
git push -f origin feature-branch
Note: This overwrites the remote history for your branch, so be cautious when others are working on the same branch.
Here are some acceptable final commit messages:
feat: implement new user loginfix: resolve null pointer exceptiontest: add tests for new user logindocs: update README with usage instructionsrefactor: simplify database query logicperf: improve caching mechanism for faster responsesAlways keep your commit message clear and concise. You should add an exclamation mark ! after the type if it’s a breaking change, for example:
feat!: remove deprecated authentication method
By following these steps, you’ll ensure that your commit history is clean, meaningful, and easy to review.
This is a highly simplified guide to clean commits. The full docs for this can be found in our contributing guidelines here.