
Commit Message with Scope
- Tech |
- 18 Feb 2021 |
- 02 Mins read
TL;DR
By providing a type and a scope in the header of a commit message, it is often a lot more obvious where changes are applied and can be found before even digging into the files that are part of the commit.
We like you too when...
We like you too when you write clear, specific and short commit messages in our project. This sentence follows me ever since I am using Git. And you know what? They are absolutely right! Having good commit messages which perfectly describe the commit history, are essential for a projects traceability, finding/fixing bugs and code documentation. This is the fourth part of my Git series and this time we will have a deeper look at the optional scope we can add right after the type in the header of the commit message.
I already briefly mentioned in my first post How We Will Use Git In The Future, the optional field scope can be used to gain a readers attention even better to tell them in which area in the code something has changed. As you by now probably can imagine, defining and using a scope depends of course on its used context. As I can't come up a this point with a general list, I have nevertheless tried to come up with some examples based on the types cheat sheet from my last post.
Examples of using scopes
Header Type with a (Scope) | Header Subject |
---|---|
feat(header) | add a new feature to the header of a website |
add(iOS14) | add iOS14 capability to appium capability config |
blog(ReactJS) | add a new blog post about ReactJS |
cut(feedback) | remove ratings feature |
fix(footer) | fix a styling bug in the footer |
bump(cypress) | increase cypress from v1.0.0 to v2.0.0 |
build(npm) | add lodash as dependency |
make/ops(artifactory) | change url to artifactory |
ci(jenkins) | add a unit test stage |
doc(readme) | update the readme file with a new TODO section |
test(search) | add a new test for the search feature |
chore(assets) | remove unused static assets |
refactor(!) | change oauth2 implementation |
style(font) | change main font to Newsreader Extra-light 200 |
optimize/perf(images) | use webp instead of jpg/png |
revert(aboutus) | revert the adding of personal emails |
rename(View) | rename the viewer |
Wrapping up
I hope you get some inspiration form the above examples for another day in your commit life. And remember, you don't have to use a scope, you can if you like to add more context for a viewer.
Cheers, take care and smile once in a while 🙂