About our git workflow, we first merge a feature into develop, then the feature into production, then we need to update dev by merging production into dev.
The question here: why do we need that last PR if the feature is already on both branches?
The short answer
Git tracks commits, not just code. Both branches have your code, but they have different merge commits. Without syncing, they drift apart and cause unnecessary conflicts later.
What actually happens
You work on FEATURE-123.
Step 1 — Merge FEATURE-123 into dev. GitHub creates merge commit A: "feature was merged into dev."
Step 2 — Merge FEATURE-123 into production. GitHub creates merge commit B: "feature was merged into production."
A and B are two different commits even though the code inside is the same. Dev knows about A but has no idea B exists.
Why it matters
With one person it's barely noticeable. But in a team:
- Dev A merges to production — commit X
- Dev B merges to production — commit Y
- Dev C merges to production — commit Z
None of those exist in dev. Git now sees two branches with very different histories. Next merge into dev? Fake conflicts — not from code differences, but from mismatched history.
The fix
After every merge to production, sync it back:
production → dev
This tells dev: "here are production's commits too, stay aligned." Usually it's a trivial merge with no actual code changes — just history alignment.
Automate it
A simple GitHub Actions workflow can do this automatically:
name: Sync production → dev
on:
push:
branches:
- production
jobs:
sync-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Merge production into dev
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout dev
git merge origin/production --no-edit --ff
if [ $? -ne 0 ]; then
echo "Merge conflict — resolve manually."
git merge --abort
exit 1
fi
git push origin dev
No extra setup needed — GitHub gives every workflow a built-in token with push access.
TL;DR
Same code, different merge commits. Sync production into dev to keep histories aligned and avoid fake conflicts.
Top comments (0)