Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Git

Git: Fix Co-authored-by Trailers Silently Disappearing From a Squash Merge’s Commit Message Because the Default Didn’t Preserve Them

- 22.10.26 - ErcanOPAK

🔀 The Attribution That Got Left Behind in the Squash

A Co-authored-by trailer only survives a merge as long as whatever process writes the final commit message actually carries it forward, and a squash merge collapses an entire branch’s worth of individual commits – each with its own trailers – into a single new commit whose message is generated fresh, typically from just the PR title and the first commit’s body, with every other commit’s Co-authored-by trailer silently left out unless someone manually re-adds it before confirming the squash.

🔎 The Problem

# Branch history before squashing - three commits, each crediting a
# different pairing partner:
commit A: "Add validation logic"
  Co-authored-by: Dev One <one@example.com>
commit B: "Fix edge case in validation"
  Co-authored-by: Dev Two <two@example.com>
commit C: "Add tests"
  Co-authored-by: Dev Three <three@example.com>

# After a default squash merge, the single resulting commit
# message is generated from the PR title/description - none of
# the three Co-authored-by trailers above are included unless
# someone notices and manually pastes them into the squash commit
# message box before confirming the merge.

✅ Fix: Collect and Re-Add the Trailers Before Confirming the Squash

  • Before confirming a squash merge, run git log –format=’%(trailers:key=Co-authored-by)’ main..branch-name (or scan the individual commits manually) to collect every Co-authored-by line across the branch, and paste the full combined set into the squash commit’s message box – most Git hosting UIs let you edit this message right before the merge completes.
  • If a repository squash-merges routinely and loses attribution often enough to matter, consider a merge strategy that preserves individual commits (a regular merge or a rebase-and-merge) for branches with meaningful multi-author history, reserving squash merges for branches where commit-level attribution genuinely doesn’t matter.
  • For history that’s already been squashed and lost its trailers, the attribution isn’t recoverable from the squashed commit itself – check the original branch’s reflog or an open PR’s commit view (which often still shows the pre-squash commits even after the squash completes) while that data is still available, rather than after it’s been garbage collected.

🚨 Why This Is Dangerous

  • The squash merge completes without any warning that attribution data was dropped – Git has no concept of a Co-authored-by trailer being ‘required’ to carry forward, so there’s no error, no confirmation prompt, nothing distinguishing a clean squash from one that just quietly erased a pairing partner’s credit.
  • This disproportionately affects contributors whose main record of having worked on something IS the Co-authored-by trailer – a junior developer or a pairing partner who didn’t open the PR themselves can lose their only visible attribution for real work, discovered (if ever) only by someone specifically checking contribution history later.

A squash merge doesn’t ask whether the trailers in the commits it’s collapsing still matter to someone – it just generates a new message from whatever the merge tool defaults to, and anything not explicitly carried forward is gone the moment the squash completes.

— Version Control Tip

Related posts:

Git: Use git cherry-pick to Copy Specific Commits Between Branches

Git: Use git cherry-pick to Copy Specific Commits Between Branches

Git: Use Interactive Rebase to Clean Up Commit History

Git: Use Interactive Rebase to Clean Up Commit History

Git: Use Tags to Mark Releases and Important Commits

Git: Use Tags to Mark Releases and Important Commits

Views: 4

Post navigation

WordPress: Fix Custom Post Type Archives Returning a 404 Because has_archive Was Never Set to True
JavaScript: Fix an IntersectionObserver Callback That Never Fires Because the Target Starts Outside the Viewport With display: none

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (980)
  • How to add default value for Entity Framework migrations for DateTime and Bool (976)
  • Get the First and Last Word from a String or Sentence in SQL (857)
  • How to select distinct rows in a datatable in C# (852)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (653)
  • Add Constraint to SQL Table to ensure email contains @ (607)
  • Average of all values in a column that are not zero in SQL (569)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (546)
  • Find numbers with more than two decimal places in SQL (475)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (980)
  • How to add default value for Entity Framework migrations for DateTime and Bool (976)
  • Get the First and Last Word from a String or Sentence in SQL (857)
  • How to select distinct rows in a datatable in C# (852)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com