Update the single purpose on the git etiquette

This commit is contained in:
Sameer Rahmani 2022-02-19 19:00:17 +00:00
parent 39629cdf31
commit a55d752c10
1 changed files with 18 additions and 0 deletions

View File

@ -38,6 +38,24 @@ Commits are the building blocks of version controlling via Git. It's obvious tha
quality will result in improvement in the overall quality of the repository.
** Single purpose commits
Oftentimes engineers working on something get sidetracked into doing too many things when working on
one particular thing like when you are trying to fix one particular bug and you spot another one,
and you cant resist the urge to fix that as well. And another one. Soon, it snowballs and you end
up with so many changes all going together in one commit.
This is problematic, and it is better to keep commits as small and focused as possible for many
reasons, including:
- It makes it easier for other people in the team looking at your change, making code reviews
more efficient.
- If the commit has to be rolled back completely, its far easier to do so.
- It's straightforward to track these changes with your ticketing system.
- It helps you mentally parse changes youve made using git log.
A commit should be a wrapper for related changes. For example, fixing two different bugs should
produce two separate commits. Small commits make it easier for other team members to understand
the changes and roll them back if something went wrong. With tools like the staging area and the
ability to stage only parts of a file, Git makes it easy to create very granular commits.
** Commit Messages
On many occasions we need to inspect the *Git* history to find something. A commit, specific changes,