loading...

Discussion on: Is git commit --amend truly *important*?

Collapse
sargalias profile image
Spyros Argalias

In this specific case I don't see a downside of using git commit --amend (unless you've already pushed), so why not use it?

Having an unclean commit history is not too harmful, all things considered, so you don't need to be perfect with it. However, a clean commit history provides some benefits:

  • Can revert to any previous commit and it will be stable, so there is less risk when reverting.
  • Can help you debug by narrowing down the bad code by finding the commit where the bug originated. You can use git bisect or find the commit manually.
  • Smaller commits can help even more with reverting, as you won't lose as many changes when you revert, and with debugging, as the bad code will be narrowed down further.
  • Easy to read back and understand the history of the codebase and features.
  • Easier to code review. E.g. when a reviewer requests changes, they can review just the relevant commits after you push the changes, rather than the whole PR from scratch.

It's quite easy to get used to using git commit --amend and git rebase -i master, it just takes some practice.