Git Commits
- How to Write a Git Commit Message
- 5 Useful Tips For A Better Commit Message
- Conventional Commits
- Atomic Git Commits
7 rules of a great Git commit message
- #1 Keep in mind: This has all been said before.
- #2 Separate subject from body with a blank line
- #3 Limit the subject line to 50 characters
- #4 Capitalise the subject line
- #5 Do not end the subject line with a period
- #6 Use the imperative mood in the subject line
- #7 Wrap the body at 72 characters
- #8 Use the body to explain what and why vs. how
Commit message structure
<type>[optional scope]: <Description>
[optional body]
[optional footer(s)]
Examples
Commit with description and breaking change footer.
feat: Allow provided config object to extend other configs
BREAKING CHANGE: `extends` key in the config file is now used for extending other config files
Commit with ! to draw attention to breaking change.
feat!: Send an email to the customer when the product is shipped
Commit with scope and ! to draw attention to breaking change.
feat(api)!: Send email to the customer when product is shipped
Commit with both! And BREAKING CHANGE footer.
chore!: Drop support for Node 6
BREAKING CHANGE: use JavaScript features not available in Node 6.
Commit with nobody
docs(CHANGELOG): Correct spelling
Commit with scope
feat(lang): Add Polish
Commit with a multi-paragraph body and multiple footers.
fix(requests): Prevent racing
Introduce a request ID and a reference to the latest request.
Also:
- Dismiss incoming responses other than from the latest request.
- Remove timeouts, which were used to mitigate the racing issue but are obsolete now.
Refs: #123
Use GitHub Copilot for Better Commit Messages in VSCode
Add to settings.json
:
// https://medium.com/medialesson/setting-up-github-copilot-for-better-commit-messages-in-vs-code-82d73fb6b016
"github.copilot.chat.commitMessageGeneration.instructions": [
{ "text": "Use conventional commit format: <type>[(scope)]: <Subject>\n\n[optional body]\n\n[optional footer(s)]" },
{ "text": "Use types: feat, fix, docs, style, ref, test, revert, chore, ci, build, perf, git" },
{ "text": "Include scope when relevant (e.g.: 'api', 'ui', 'auth', 'admin/users')" },
{ "text": "Separate subject from body with a blank line" },
{ "text": "The subject should use the imperative mood, be capitalised, short, clear, concise, descriptive, meaningful, and communicate the context surrounding a change" },
{ "text": "Limit the subject line to 50 characters" },
{ "text": "Do not end the subject line with a period" },
{ "text": "The body should explain what and why vs. how" },
{ "text": "Wrap the body at 72 characters" },
{ "text": "Reference issue numbers with # prefix" },
{ "text": "Use the footer to reference breaking changes with 'BREAKING CHANGE: <description>'" },
{ "text": "Use the footer to reference issues with 'Closes #<issue-number>'" },
{ "text": "Use the footer to reference links that may exceed 72 characters with 'More: https://very.long.link/lorem-ipsum-excepteur-anim-dolore-et-laborum-officia-nostrud-nisi-tempor-in.-Sint-laboris-ex-ea-ex/'" },
{ "text": "Follow the constraints defined in the gitlint configuration, in order of precedence: ./.gitlint, ~/.config/gitlint/gitlint.cfg" }
],
Tooling
References
- Pro Git book
- Como fazer um commit semântico
- Conventional Commits: Cheat Sheet
- Git e Github na prática: Guia do iniciante
- A guide to improve the Git(Hub) flow and commits messages
- Git Flow vs GitHub Flow | Alex Hyett
- What are the pros and cons of git-flow vs github-flow?
- Choosing the Right Git Workflow for Your Project: GitFlow, GitHub Flow
- Workflows Comparison: Git Flow Vs GitHub Flow - Fresh Consulting
- Git(Hub) Flow, Trunk Based Development, and Code reviews
- Setting up GitHub Copilot for Better Commit Messages in VS Code
Top comments (0)