Why are atomic commits a best practice in Git?

15 / Feb / 2015 by Aseem Bansal 0 comments

Atomic means all or nothing – either everything succeeds or all fails. Git is known to have atomic operations i.e. an environment issue will not cause git to commit half of the files into the repository and leave the rest.

So what are we doing talking about atomic commits when all operationsĀ are already atomic in git?

When we talk about atomic commits as a best practice we mean every commit should be atomic in terms of features present in your app. Every commit should be related to one feature only. Do not make a commit which is related to even two features. The reason is simple. It makes keeping track of the relevant changes difficult. After a while if a bug occurs then it will be difficult for everyone, you included, to track down where things went wrong. Different features really belong to different git branches not in the same commits.

Tag -


Leave a comment -