Making Git work the way you want

Another question that followed my recent Git emails was, " I assume you use rebase over merge?"

The short answer is "yes". I like to keep the history of my repositories clean and simple to read by keeping the logs linear and not full of merge commits.

The longer answer is that I do merges, but only fast-forward merges, at least by default.

If, when merging, Git can fast-forward my branch to the latest commit without creating a merge commit, it will do so.

If not, I can then rebase my changes to make them linear and fast-forwardable. Alternatively, if the commits have already been pushed and cannot be overwritten, I can explicitly allow a non-fast-forward merge in that situation.

I have Git configured to work this way as that's how I want it to work, and that configurability is something I like about Git.

If you want to see how I have Git configured, my settings are in my dotfiles repository (note this file is written in the Nix language as I use Nix to manage my configuration).

If you're working in a team, I'd suggest having a common configuration for everyone and defined rules for how you're going to use Git (branch names, merge or rebase, etc) to avoid inconsistencies.

- Oliver

P.S. Are you still using Drupal 7 and don’t know what’s involved to upgrade to Drupal 10? Book a Drupal 7 upgrade consultation call or an upgrade roadmap.

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.