An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
OhSnap! Instantly Improve Your Git Commit Messages
The "OhSnap!" series explores bite-sized tips that I have learned and that you can apply today.
Sometimes becoming a better developer comes down to slight course corrections in our daily workflows.
Recently I came across this awesome article by, Chris Beams, that explains how to do that with an action we all perform git commits.
The Tip
Write git commits imperatively, not as a description.
The Wrong Way
git commit -m "Added new page"
git commit -m "Fixed margin above the hero banner for a better layout"
git commit -m "This adds a new color"
The Right Way
git commit -m "Add About page"
git commit -m "Fix spacing above the hero banner"
git commit -m "Change headline color"
What is the difference?
The second versions are all actions. They sound abrupt, but they are meant to instruct what is about to happen, not describe why you did something.
Notice that even as imperative actions, they still communicate with specificity on exactly what was done.
At the end of the day, all we really want to know is what this commit will do to our main branch if merged. The body of the commit or a pull request can always hold the details of why you did something.
How do I write these correctly?
Chris Beams gives a fantastic sentence to test your commits against. If the sentence still makes sense afterwards, then it is a strong imperative commit.
If applied, this commit will your message here
git commit -m "If applied, this commit will Change headline color"
vs.
git commit -m "If applied, this commit will changes new color"
I highly encourage you to read the full article, as there are many more great tips in there.
Original Link: https://dev.to/gedalyakrycer/ohsnap-instantly-improve-your-git-commit-messages-45fg
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To