Engineering Culture: Keeping a Clean Commit History

  • To keep a clean commit history of your code. Code is communication for both other engineers and your future self. The cleaner it is, the more sane the readers will be.
  • To utilize `git blame` to its full potential. `git blame` is a tool often used to try and figure out the latest change made to a piece of code and trace back to the commit that made the change. If there are many “fix-up” commits obfuscating the actual commit that changed the code’s behavior, it makes it very hard to understand the author’s original intention.

Interactive Rebasing to Edit Commits

Interactive rebasing is a powerful tool in git that allows you to locally traverse back in history to previous commits, make changes, and essentially rewrite history.

  • Commit A
  • Commit B
  • Commit C
git rebase -i 400d63a771fc0eefd7409da4bfa6a1f37bfff17b^

Exploring Other Options

Interactive rebasing is a powerful tool. Editing old commits in place is just one of the many things you can do with it; you can also:

The Distru Team (May 2021)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Johnny Ji

Johnny Ji

13 Followers

Building the future Cannabis supply chain software! We’re a technical team looking for product-driven engineers. Our stack is React, TS, GraphQL, & Elixir :D