(EN) Semantic Commit Messages for GIT
Yazdığım bu makalenin Türkçe versiyonuna bu linkten ulaşabilirsiniz.
The word “Semantic” means “meaningful”. In fields such as computer science and software development, it is used to equip computers with structural and semantic information to assist with understanding and interpretation.
The “Semantic Commit Messages” approach is a method in software development that ensures changes in code are clearly and consistently specified. This approach enables developers to express the purpose, type, and scope of their changes more clearly.
In the GIT universe, each code change is referred to as a "commit" and is accompanied by a message explaining the change. The Semantic Commit Messages approach suggests that commit messages be written in a specific format and standard usage style. This topic is relevant to developers at all levels, from junior to senior.
This format typically follows the structure of <type>(<scope>): <subject>
“<type>” specifies the type of change being made. (e.g. “feat” for a new feature)
“<scope>” specifies the scope of the change, which could be the name of the project in a repository with multiple projects, or the specific section of a project being changed. (optional)
“<subject>” describes the summary of the change. (in present tense)
Commonly used <type> tags include:
- feat: (adding a new feature for users)
- fix: (fixing a bug for users)
- docs: (changes to documentation)
- style: (formatting, missing semicolons, indentation, quotes, trailing commas, etc.)
- refactor: (restructuring code, such as renaming a variable)
- perf: (production changes related to backwards-compatible performance improvements)
- test: (adding missing tests, reorganizing tests)
- chore or build: (changes and improvements that do not affect the user, such as modifying .gitignore or package dependencies)
Providing examples of commit messages based on this information can help reinforce the topic.
- Example of purpose: “feat: added customer search feature” (Here, the purpose is to add a new feature)
- Example of type: “style: added missing semicolons” (Here, the type is related to code formatting)
- Example of scope: “fix(auth): user login error fixed” (Here, the scope indicates that the change is limited to a section called “auth”)
Extra:
To draw attention to a change and commit, an exclamation mark (!) should be added before the colon (:). For example:
feat!: sends an email to the customer when a product is shipped
Thank you for your time. I hope it was a helpful explanation.
Source:
https://nitayneeman.com/posts/understanding-semantic-commit-messages-using-git-and-angular
https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716