logo
podcast Podcast
get help Get Unstuck

Tell a story with your git commits

It doesn't have to be a long story

Joel Clermont
Joel Clermont
2024-09-10

As I'm working on a feature, I like to make multiple smaller commits with descriptive messages.

Here is an example of my commit history on a recent feature adding a new endpoint related to attaching notes to other resources:

  • add API spec
  • stub out migration, model, factory, enum, and controller
  • wire up parent relationships
  • update spec for proper resource wrapping
  • introduce new notes permissions
  • implement endpoints
  • refactor some common logic for notes

For context, this is less than a day of work. Each commit might represent anywhere from 15 minutes to 2 hours of effort.

Also, when I'm working on a feature, sometimes I'll bump into a semi-unrelated issue, which it makes sense to clean up at the same time.

For example, maybe it's something as simple as noticing a spelling error in a file name. Or maybe you notice one older file not following a current standard, and it's a very small, simple refactor.

You could open a separate issue, but it's a little silly to do that. You could just fix it in less time.

I will definitely isolate these changes into their own commit as well:

  • fix psr-4 structure for tests
  • ide-helper update

I like isolated commits for two reasons:

  1. It makes it easier when I'm creating the PR later to remember any specific things that I want to highlight for the reviewer.
  2. If one of my off-feature changes gets rejected, it's super easy to revert that one isolated commit.

Here to help,

Joel

P.S. Would you like some help tightening up the process for your Laravel team?

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.