Use this when you work in a public fork clone locally but want to keep your full WIP history in a private mirror repo.
Example mapping used here:
- Local repo:
~/repos/pqrs-org/Karabiner-Elements-user-command-receiver - Public remotes:
origin=nikivdev/Karabiner-Elements-user-command-receiverupstream=pqrs-org/Karabiner-Elements-user-command-receiver
- Private mirror remote:
private=nikivdev/Karabiner-Elements-user-command-receiver-i
- Move feature-branch work onto
mainlocally. - Sync with latest
origin/main. - Push local
mainto a private fork/mirror.
# from repo root
git stash push -u -m "move-to-main"
git switch main
git merge --ff-only <feature-branch>If --ff-only fails, do a normal merge or cherry-pick intentionally.
If you want strict origin-only sync (no upstream automation):
git fetch origin --prune
git rebase origin/mainThen reapply stash:
git stash apply stash@{0}Avoid runtime artifacts (out/logs/*, todo scratch files, etc.).
git add -A -- ':!out/logs/cli.log' ':!out/logs/trace.log' ':!.ai/todos/todos.json'
git commit -m "<message>"# one-time creation
gh repo create nikivdev/<repo>-i --private --source=. --remote=private --disable-wiki
# publish branch
git push -u private mainf sync can use jj integration and may rebase against upstream depending on repo setup.
That is useful in normal fork workflows, but if you need strict origin-only syncing for a private mirror flow, prefer explicit Git commands:
git fetch origin --prune
git rebase origin/mainThen use Flow for commit/review as usual.
Symptoms:
jjconflict commits- files like
.jjconflict-base-*/.jjconflict-side-*
Recovery pattern:
- stash uncommitted work (
git stash push -u) - create clean branch from
origin/main - cherry-pick your intended commits
- reapply stash
- continue from clean branch and move pointer back to
main
git stash push -u -m "recovery"
git fetch origin --prune
git switch -c main-clean origin/main
git cherry-pick <commit1> <commit2>
git stash apply <stash-with-real-work>
git branch -f main main-clean
git switch mainIf this repo is now private-first for your local work:
git push -u private mainand keep origin/upstream as fetch sources for rebases.