oliverdavies.uk/content/node.2885a415-17fb-4374-8070-0be55407af6c.yml

104 lines
4.5 KiB
YAML

uuid:
- value: 2885a415-17fb-4374-8070-0be55407af6c
langcode:
- value: en
type:
- target_id: daily_email
target_type: node_type
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
revision_timestamp:
- value: '2025-05-11T09:00:14+00:00'
revision_uid:
- target_type: user
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
revision_log: { }
status:
- value: true
uid:
- target_type: user
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
title:
- value: 'Merging without merge commits'
created:
- value: '2024-05-12T00:00:00+00:00'
changed:
- value: '2025-05-11T09:00:14+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: /daily/2024/05/12/merging-without-merge-commits
langcode: en
body:
- value: |
<p>Since I posted about <a href="/daily/2024/05/10/optimise-for-revertability">optimising for revertability</a>, I've received a few questions about how I avoid merge commits when working with Git.</p>
<p>This is an extract from my <code>.config/git/.config</code> file:</p>
<pre><code class="ini">[merge]
ff = "only"
[pull]
ff = "only"
rebase = true
</code></pre>
<p>This changes the behaviour of when I run <code>git pull</code> to always include <code>--rebase</code> by default and to only allow fast-forward merges and pulls.</p>
<p>Only allowing fast-forward merges avoids merge commits as Git can just move the pointer for the branch to the latest commit.</p>
<p>If I can't do a fast-forward merge, I need to rebase first to update everything and bring it up to date.</p>
<p>Sometimes, when working in team, merge commits will still creep in sometimes and there are situations where you can only create a merge commit.</p>
<p>In this situation, I can do <code>git merge --ff</code> to allow a merge commit temporarily, but this is the exception instead of the default.</p>
<blockquote>
<p>Hint: there's a lot more information on the configuration and arguments if you run and read <code>man git-merge</code>.</p>
</blockquote>
<p>When working with online tools such as GitHub and GitLab, I avoid any options like <code>Squash and merge</code> or <code>Create a merge commit</code> and will use rebase options, although I've seen where different commit IDs have been generated when merged in the UI, which is why I prefer to do merges locally.</p>
<p>Or use <a href="/daily/2023/06/17/avoid-git-merge-hell-with-trunk-based-development">trunk-based development</a> and don't work on topic branches at all.</p>
format: full_html
processed: |
<p>Since I posted about <a href="/daily/2024/05/10/optimise-for-revertability">optimising for revertability</a>, I've received a few questions about how I avoid merge commits when working with Git.</p>
<p>This is an extract from my <code>.config/git/.config</code> file:</p>
<pre><code class="ini">[merge]
ff = "only"
[pull]
ff = "only"
rebase = true
</code></pre>
<p>This changes the behaviour of when I run <code>git pull</code> to always include <code>--rebase</code> by default and to only allow fast-forward merges and pulls.</p>
<p>Only allowing fast-forward merges avoids merge commits as Git can just move the pointer for the branch to the latest commit.</p>
<p>If I can't do a fast-forward merge, I need to rebase first to update everything and bring it up to date.</p>
<p>Sometimes, when working in team, merge commits will still creep in sometimes and there are situations where you can only create a merge commit.</p>
<p>In this situation, I can do <code>git merge --ff</code> to allow a merge commit temporarily, but this is the exception instead of the default.</p>
<blockquote>
<p>Hint: there's a lot more information on the configuration and arguments if you run and read <code>man git-merge</code>.</p>
</blockquote>
<p>When working with online tools such as GitHub and GitLab, I avoid any options like <code>Squash and merge</code> or <code>Create a merge commit</code> and will use rebase options, although I've seen where different commit IDs have been generated when merged in the UI, which is why I prefer to do merges locally.</p>
<p>Or use <a href="/daily/2023/06/17/avoid-git-merge-hell-with-trunk-based-development">trunk-based development</a> and don't work on topic branches at all.</p>
summary: null
field_daily_email_cta: { }