How can I prevent foxtrot merges in my 'master' branch?
<p>A foxtrot merge is a merge where 'origin/master' merges in as a 2nd (or later) parent, like so:</p>

<p><a href="https://i.stack.imgur.com/yZMCS.png"><img src="https://i.stack.imgur.com/yZMCS.png" alt="Commit &#39;D&#39; is a foxtrot merge because &#39;origin/master&#39; is its 2nd parent."></a></p>

<p><sup><i>Commit 'D' is a foxtrot merge because 'origin/master' is its 2nd parent. Notice how first-parent history from 'origin/master' contains commit 'B' at this moment. </i></sup></p>

<p>But in my git repo I need all merges involving 'origin/master' to keep 'origin/master' as the 1st parent. Unfortunately git doesn't care about parent-order when it evaluates whether a commit is eligible for fast-forward. This causes the first parent history on my master branch to sometimes lose commits that used to be there (e.g., output of "git log --first-parent").</p>

<p>Here's what happens when commit 'D' from the earlier diagram is pushed:</p>

<p><a href="https://i.stack.imgur.com/ACgpr.png"><img src="https://i.stack.imgur.com/ACgpr.png" alt="How can I prevent this push? First-parent history of &#39;origin/master&#39; no longer contains commit &#39;B&#39; after the foxtrot merge is pushed!"></a></p>

<p><sup><i>How can I prevent this push? First-parent history of 'origin/master' no longer contains commit 'B' after the foxtrot merge is pushed!</i></sup></p>

<p>Obviously no commits or work are actually lost, it's just that in my environment I really need "git log --first-parent" to be a stable accumulative record of commits - if you like, a kind of "Write-Once Read-Many" (WORM) database. I have scripts and processes that use "git log --first-parent" to generate changelogs and release notes, as well as to manage ticket transitions in my ticketing system (JIRA). Foxtrot merges are breaking my scripts!</p>

<p>Is there some kind of pre-receive hook I could install in my git repositories to prevent foxtrot merges from getting pushed?</p>

<p><sup><i>p.s. The commit graphs in this stackoverflow question were generated using <a href="http://bit-booster.com/graph.html">http://bit-booster.com/graph.html</a>.</sup></i></p>