| name | mirror-master-with-upstream |
| description | Fast-forward the fork's master branch to match upstream/master exactly, then push it to origin. Use this to keep the fork's master as a clean mirror before or after a merge-upstream-into-branch run. |
Mirror master with upstream
Keeps thpoll83/qmk_firmware:master as a byte-for-byte mirror of qmk/qmk_firmware:master.
This branch should never carry custom commits — all PolyKybd work lives on PolyKybd.
Repo root: /home/thpoll/Repos/qmk_firmware on the user's machine,
/home/user/qmk_firmware in a Claude Code web/remote container.
Step 0 — container prerequisites (skip on the user's own machine)
A fresh remote-container clone has neither the upstream remote nor a local
master, and its history is shallow — which makes every "how far behind"
answer below wrong until fixed. Establish all three first:
git rev-parse --is-shallow-repository
git fetch origin --unshallow --no-recurse-submodules
git remote add upstream https://github.com/qmk/qmk_firmware
git fetch upstream master --no-recurse-submodules
git fetch origin master --no-recurse-submodules
--no-recurse-submodules throughout: the qmk/* submodule repos are not
proxy-authorized, so a plain fetch ends in Could not access submodule 'lib/chibios' noise that hides the real result (the fetch itself still worked).
Procedure
-
Verify master has no local-only commits — if it does, stop and warn the user rather than silently overwriting their work:
git fetch upstream
git log --oneline upstream/master..origin/master
If any commits are listed, report them and abort. Ask the user whether those commits were intended for PolyKybd instead.
-
Check how far behind master is:
git log --oneline master..upstream/master | wc -l
git log --oneline master..upstream/master | head -10
Report the count and the most recent 10 upstream commit messages. If the count is 0, report "master is already up to date" and stop.
-
Fast-forward master. Prefer the checkout-free form — it is the only one
that works when there is no local master (the container case), and it is the
better choice even when there is one, because checking out master would swap the
whole working tree mid-session and invalidate any .build/ output:
git merge-base --is-ancestor origin/master upstream/master && echo "fast-forward OK"
git branch -f master upstream/master
The --is-ancestor test is the --ff-only safety check: it fails exactly
when master has diverged. If it fails, abort and report the divergence — do not
force-reset without explicit user instruction.
Classic form (user's machine, master not otherwise busy):
git checkout master && git merge --ff-only upstream/master
-
Push to origin — name both ends, so it works whatever branch is checked out:
git push origin master:master
-
Return to the previous branch so the user's working context is unchanged:
git checkout -
Not needed after the checkout-free form in step 3 — nothing moved.
-
Report:
- How many commits were pulled in.
- New HEAD SHA and the upstream commit message it corresponds to.
- Reminder: run
/merge-upstream-into-branch next if you also want PolyKybd updated.
Notes / pitfalls