Version control
Committing code
When working on code you will need to commit your changes to the repository. This is a way of saving your changes and making them available to others. It is also a way of keeping track of changes and rolling back to previous versions if necessary.
Key concepts
- Commit often and with a clear purpose.
- Keep commits small and focused.
- Commit messages should follow the Conventional Commits standard.
Commit frequency and size
Commit often to keep your changes small and focused. This makes it easier to review code or rollback to previous commits if necessary.
Commits messages
Well-named commits are essential for long-term project development, making the repository a source of valuable information and change history. Sticking to the established convention in naming commits will speed up the team’s work during code reviews, but it will also be useful for the committer to keep track of the changes they have made.
Conventional Commits
Using Conventional Commits is a great way to create clear history changes. This specification allows you to:
- Categorise by type (fix, feat, etc.)
- Keep a structured commit history
- Automatic changelog generation (optionally)
The commit message consists of three parts described below:
Type communicate intent of changes. Possible types:
fix
- bug fixesfeat
- code featuresbuild
- adding, removing, or upgrading dependencieschore
- technical or preventative maintenance including configs and file renames or moves. It’s a type of change that does not affect the content of the source code or testsdocs
- adding and changing documentation, including readme.md filestyle
- styles updating without changing product functionalitytest
- relating to running testsrefactor
- refactoring existing codeci
- changes to CI or CD configurationremove
- removing a feature
Scope is used to tag a package or the module that the commit affects.
Description is the title of the commit. If more detailed information is needed, it should be provided in the <body>
of the commit.
Example:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
To see more information about writing Conventional Commits visit the official specification:
Conventional CommitsAnd if you are using VSC download Conventional Commits extention.