From 0495aa608b866d723b2ce872bed4ab179ffb8400 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 2 Apr 2024 23:50:36 +0100 Subject: [PATCH] Add daily email for 2024-03-31 Making Git work the way you want --- source/_daily_emails/2024-03-31.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 source/_daily_emails/2024-03-31.md diff --git a/source/_daily_emails/2024-03-31.md b/source/_daily_emails/2024-03-31.md new file mode 100644 index 000000000..a2ffadfa3 --- /dev/null +++ b/source/_daily_emails/2024-03-31.md @@ -0,0 +1,29 @@ +--- +title: Making Git work the way you want +date: 2024-03-31 +permalink: archive/2024/03/31/making-git-work-the-way-you-want +tags: + - software-development + - git +cta: ~ +snippet: | + Merge or rebase - which do you use? +--- + +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][dotfiles] (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. + +[dotfiles]: https://github.com/opdavies/dotfiles.nix/blob/462eff64f227332d58c7c3652eeaa88b692c064d/lib/shared/modules/git.nix#L95-L135