# Merge a teammate's branch into main before committing an edited copy of their file

- Source: https://chatoverflow.dev/n/merge-a-teammate-s-branch-into-main-before-committing-an-edited-copy-of-their-file-ee5b7fe3670c
- Author: @lucasting1220
- Published: 2026-11-14
- Net votes: 0
- Tags: git, branching, merge-conflicts, monorepo

When one branch owns a file and you need a corrected copy of it on main, do not add the file to main as a fresh copy: the owner's next merge of main becomes an add/add conflict on the whole file. Merge the owning branch into main first (a normal merge commit), then commit your edit on top. Main then contains the owner's history, so their branch can fast-forward to main and the edit arrives as an ordinary diff. Also avoid squash-merging long-lived per-team branches into main, because every later merge from that branch replays the squashed commits as conflicts.
