Ever wondered how to write commit messages for Git? Or maybe you’ve written messages that were technically correct but still caused murmurs in your team?
Well, that ends here and now. We’ve all been victims of this anomaly, and the way forward is simple: improve ourselves and share knowledge.
Let's dive in...
What is Git?
Git is a distributed version control system that manages versions of source code or data. Programmers often use it to collaborate on projects efficiently.
Git lets you work locally, track changes to files, and push those changes to remote repositories like GitHub or Bitbucket for collaboration.
More about git
Git official
How to commit
A commit is made by running git commit -m "some-message" with -m flag denoting message and "some-message" being the details of what you are committing, which is the main point of our article today.
Commit messages aren’t about long paragraphs, perfect grammar, or capitalization. They are about clarity, brevity, and readability.
Common Commit Message Tags
Using standard tags makes Git history clear and helps your team understand the purpose of each change.
feat:
when the commit adds or changes functionality in a way that matters to users e.gfeat: add GitHub OAuth loginfix:
when the commit fixes a bug that existed e.gfix: handle API rate limitsdocs:
when only the documentation changes (no code behavior changes). e.gdocs: update README with setup instructionsstyle:
Code style or formatting changes that do not affect logic or behavior. e.gstyle: fix indentationrefactor:
Code changes that improve structure or readability without changing behavior. e.grefactor: simplify GitHub client logictest:
Adds, updates, or fixes tests only. e.gtest: add unit tests for loginchore:
Maintenance tasks that don’t affect application behavior
(dependencies, configs, scripts). e.gchore: update GitHub Actions workflowrevert:
Reverts a previous commit e.grevert: undo login featureperf:
Changes that improve performance e.gperf: optimize database queriesbuild:
Changes that affect the build system or external dependencies. e.gbuild: update dependencies
It is also good practice to write your commits in the present tense. Instead of "feat: added login functionality", do "feat: add login functionality"
"That's how dad did it, that's how America does it, and it's worked out pretty well so far"
~Iron Man 2008
This sets the base for linear and standard collaboration works and i hope you are a better commiter now that you've come this far.
Like my boss would say, leave with a quote to appear smart, i will leave you with this:
"Git commit messages are how we communicate to our future selves."
Happy committing, and may your Git history be forever clean and understandable.
Bye 👋
Top comments (0)