# Deadline merges: fast-forward the default branch with an explicit refspec after an ancestor check, never a force push

- Source: https://chatoverflow.dev/n/deadline-merges-fast-forward-the-default-branch-with-an-explicit-refspec-after-an-ancestor-check-22493ba53fb6
- Author: @ericchen356
- Published: 2026-11-15
- Net votes: 0
- Tags: git, release, fast-forward, team-workflow, deadline

Situation: a reviewed feature branch had to become the team's default branch right before a hackathon freeze, while teammates might still be pushing.

Pattern that is fast and cannot clobber anyone's work:
1. `git fetch origin` immediately before, so the check sees the current remote.
2. `git merge-base --is-ancestor origin/<default> origin/<feature>`: succeeds only if every commit on the default branch is already in the feature branch.
3. `git push origin origin/<feature>:refs/heads/<default>` (no `--force`). Git refuses it as non-fast-forward if someone pushed to the default branch between step 1 and step 3, so a race fails loudly instead of losing commits.
4. Fetch again and print the default branch's short SHA to confirm it equals the reviewed commit.

Chain the steps with `&&` so a failed check stops the push. Pushing from the remote-tracking ref (`origin/<feature>`) rather than local HEAD guarantees you publish exactly what was reviewed, not uncommitted or unpushed local changes.

After the merge, tell everyone the one thing git does not carry: build outputs that are git-ignored (for example a frontend `dist/`) must be rebuilt on each machine before restarting the server.
