The purpose of this gist is to gather the best practices for using git in one convenient location and to educate more people about the standards. Especially when collaborating with others, it is essential to establish conventions to follow.
A commit should be a wrapper for related changes. For example, fixing two different bugs should produce two separate commits. It is better to keep commits as small and focused as possible for many reasons, some of them include:
- It makes it easier for other developers in the team and reviewers to understand the changes, making code reviews more efficient
- If the commit has to be rolled back completely, it's far easier to do so
- It helps you parse changes you've made using the git log
I suggest working in smaller portions and frequently committing to your progress instead of striving for perfection. This approach is particularly beneficial when working on a feature branch that may take a while to complete as it ensures that your code remains up-to-date and minimizes potential conflicts.
I'd like to remind you that writing informative and detailed commit messages that give a brief overview of the changes made within a commit is essential for the convenience of others and your own future reference. It's important to consider that your team members must comprehend the message and precisely what changes you have made.
- Use the imperative, present tense: "change" not "changed" nor "changes" for your commit message (written in lower case)
- Use the body to explain what and why the change was made. This part should be added only when necessary
- Keep it brief, wrap the subject line at 50 characters and the body at 72 characters
- Add an empty line underneath the commit message, and begin writing the body (description)
- Do not end the commit message(subject line) with a period
- Remove unnecessary punctuation marks
<type>(<optional scope>): <subject>
<BLANK LINE>
<optional body>
<BLANK LINE>
<optional footer(s)>
feat: add foo support
^--^ ^------------^
| |
| +-> Summary(commit message subject line) in present tense
|
+-------> Type: chore, docs, feat, fix, refac, style, or test
"type" must be one of the following:
feat: new feature for the user, not a new feature for a build scriptfix: bug fix for the user, not a fix to a build scriptdocs: changes to the documentationstyle: formatting, missing semi-colons, etc; no production code changerefactor: refactoring production code, eg. renaming a variabletest: adding missing tests, refactoring tests; no production code changechore: regular code maintenance and updating grunt tasks etc; no production code change (eg: change to .gitignore file or .prettierrc file)build: build-related changes, for updating build configuration, development tools or other changes irrelevant to the user (eg: npm related/ adding external dependencies/ podspec related)perf: code change that improves performance
fix: prevent racing of requests
Introduce a request id and a reference to the latest request. Dismiss
incoming responses other than from the latest request.
Resolves: #123
fix: remove string template from client code
It is incompatible with IE
docs: prepare CHANGELOG for version x.x.x