From a55d752c1020b0b30dd6b00946984d3982a259ba Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sat, 19 Feb 2022 19:00:17 +0000 Subject: [PATCH] Update the single purpose on the git etiquette --- orgs/essays/git-etiquette.org | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/orgs/essays/git-etiquette.org b/orgs/essays/git-etiquette.org index b27497a..7120aaf 100644 --- a/orgs/essays/git-etiquette.org +++ b/orgs/essays/git-etiquette.org @@ -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 can’t 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, it’s far easier to do so. +- It's straightforward to track these changes with your ticketing system. +- It helps you mentally parse changes you’ve 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,