okhp3-replit-github-sync
OverKill Hill P³ · overkillhill.com · github.com/OKHP3
Replit's Git UI can be a useful surface, but it is not the source of truth when
the workspace and GitHub disagree. This skill establishes the actual Git state,
preserves local work, and uses an explicit integration path instead of retrying
a rejected push until it happens to work.
It requires a Git checkout with an origin remote. A connected GitHub
capability is optional for hosted compare, pull-request, and merge actions;
local Git remains authoritative for the Replit working tree.
Scope
| In scope |
Out of scope |
Diagnose one Replit checkout against origin |
Multi-clone maintenance or branch cleanup |
| Commit reviewed local work, pull, and normally push |
Force-push, history rewriting, or deleting refs |
| Prepare a branch PR and an approved squash merge |
Bypassing required review or status checks |
| Verify GitHub and local branch alignment after sync |
Solving merge conflicts without owner input |
Operating contract
Treat the Replit UI error as a symptom, not a diagnosis. Record the
repository root, current branch, remotes, current status, and the default
base ref before changing anything:
git status --short --branch
git remote -v
git symbolic-ref --quiet --short refs/remotes/origin/HEAD || true
git log --oneline --decorate -8
Default to origin/main only when that is the verified default branch; do
not silently substitute main for a repository with another default.
Inspect local changes before staging. Check for merge/rebase state,
conflict markers, credentials, .env files, or generated output that is not
clearly meant to be committed. Run git diff --check and show the intended
commit scope. If the user has not authorized a commit, produce the review
and proposed commit message, then stop.
Fetch without pruning, then measure the relationship explicitly:
git fetch origin
git rev-list --left-right --count HEAD...<base-ref>
git log --oneline --left-right HEAD...<base-ref>
The left count is local-only commits; the right count is remote-only
commits. A PUSH_REJECTED normally means the right side is non-zero. Do not
retry git push, use --force, or discard local files to make the error
disappear.
Choose the least-risk path from the actual state:
| State |
Safe action |
| Working tree clean; behind only |
git pull --ff-only origin <base> and verify. |
| Local changes only; no remote-only commits |
Review, stage only the approved paths, commit, then git push origin <branch>. |
| Local and remote have both advanced on the default branch |
Stop for an explicit integration decision. Prefer moving the local work to a feature branch and using a PR; never force-push shared history. |
| Feature branch needs current base |
Fetch, then merge the base into the feature branch for a normal push, or rebase only with explicit authorization and a --force-with-lease plan. |
| Conflicts, detached HEAD, missing remote, or protection failure |
Do not guess a resolution. Report the exact state and smallest next action. |
Do not use a bare git pull because its merge/rebase behavior is host
configuration-dependent. Use --ff-only for a pure update and an explicit
merge or rebase decision for divergence.
For work that belongs on a non-default branch, push that branch and create
or update a pull request targeting the verified base. A squash merge is a
pull-request action, not a substitute for reconciling a rejected push.
Immediately before an approved merge, verify the PR head SHA, target branch,
approvals, and required checks. Merge only when the user authorizes that
exact PR and strategy.
After every successful integration, fetch again and prove the result:
git fetch origin
git status --short --branch
git rev-list --left-right --count HEAD...<base-ref>
git log -1 --oneline <base-ref>
A clean status alone is insufficient: report the pushed or merged commit
SHA, the verified target ref, and whether local HEAD matches the intended
remote ref. Run the project's relevant validation before claiming an app
change is ready.
GitHub capability adapter
When the host exposes a connected GitHub capability, use the connection the
user has made available to inspect repository metadata, compare commits, read
PR/check state, create or update a PR, and perform an explicitly approved
merge. Confirm that the connector's repository and account match the local
origin before any write.
Do not embed a connector ID, token, or account name in this portable package.
Those are host- and user-specific. If the connector is unavailable, perform
local Git inspection and hand back the exact PR or merge action that requires a
connected GitHub surface.
PUSH_REJECTED recovery
For the common error "the remote has commits that are not in the local
repository":
- Preserve the working tree; do not reset, stash-drop, or force-push.
- Fetch
origin and show the ahead/behind counts and commit subjects.
- If the checkout is merely behind and clean, fast-forward it.
- If the checkout has local commits as well, identify whether they are on the
default branch or a feature branch and use the decision table above.
- Resolve only user-approved conflicts. If this workflow started the merge or
rebase and no subsequent user edits occurred, aborting that operation is a
safe recovery option; otherwise stop and preserve the state for review.
- Push normally, then re-fetch and verify the remote contains the expected
commit. A second rejection means stop and re-inspect rather than escalating
to a force push.
Output contract
Return:
- verified repository root,
origin URL, current branch, and base ref;
- working-tree and ahead/behind state before any write;
- reviewed commit scope and every commit, push, PR, or merge actually made;
- the connector state used, or why hosted actions were not available;
- conflict/protection/authorization blockers and the smallest safe next step;
- post-action
git status, target-ref comparison, commit SHA, and relevant
validation result.
About
Built by Jamie Hill · OverKill Hill P³
Published at github.com/OKHP3
Part of the OKHP3/skillz Agent Skill library.
MIT License -- free to use, fork, and adapt. A nod to the source is appreciated.
1---2name: okhp3-replit-github-sync3description: Recover and maintain safe GitHub synchronization for a Replit project. Use when Replit reports PUSH_REJECTED, cannot commit through its UI, or a project needs to pull, commit, reconcile, merge, or push changes to its GitHub default branch. Also activate for "Replit GitHub out of sync", "push rejected", "sync Replit to origin/main", or a safe branch-to-main squash merge. Do not use to force-push, discard unreviewed work, or bypass branch protection.4license: MIT5---67# okhp3-replit-github-sync89**OverKill Hill P³** · [overkillhill.com](https://overkillhill.com) · [github.com/OKHP3](https://github.com/OKHP3)1011Replit's Git UI can be a useful surface, but it is not the source of truth when12the workspace and GitHub disagree. This skill establishes the actual Git state,13preserves local work, and uses an explicit integration path instead of retrying14a rejected push until it happens to work.1516It requires a Git checkout with an `origin` remote. A connected GitHub17capability is optional for hosted compare, pull-request, and merge actions;18local Git remains authoritative for the Replit working tree.1920## Scope2122| In scope | Out of scope |23|---|---|24| Diagnose one Replit checkout against `origin` | Multi-clone maintenance or branch cleanup |25| Commit reviewed local work, pull, and normally push | Force-push, history rewriting, or deleting refs |26| Prepare a branch PR and an approved squash merge | Bypassing required review or status checks |27| Verify GitHub and local branch alignment after sync | Solving merge conflicts without owner input |2829## Operating contract30311. Treat the Replit UI error as a symptom, not a diagnosis. Record the32 repository root, current branch, remotes, current status, and the default33 base ref before changing anything:3435 ```bash36 git status --short --branch37 git remote -v38 git symbolic-ref --quiet --short refs/remotes/origin/HEAD || true39 git log --oneline --decorate -840 ```4142 Default to `origin/main` only when that is the verified default branch; do43 not silently substitute `main` for a repository with another default.44452. Inspect local changes before staging. Check for merge/rebase state,46 conflict markers, credentials, `.env` files, or generated output that is not47 clearly meant to be committed. Run `git diff --check` and show the intended48 commit scope. If the user has not authorized a commit, produce the review49 and proposed commit message, then stop.50513. Fetch without pruning, then measure the relationship explicitly:5253 ```bash54 git fetch origin55 git rev-list --left-right --count HEAD...<base-ref>56 git log --oneline --left-right HEAD...<base-ref>57 ```5859 The left count is local-only commits; the right count is remote-only60 commits. A `PUSH_REJECTED` normally means the right side is non-zero. Do not61 retry `git push`, use `--force`, or discard local files to make the error62 disappear.63644. Choose the least-risk path from the actual state:6566 | State | Safe action |67 |---|---|68 | Working tree clean; behind only | `git pull --ff-only origin <base>` and verify. |69 | Local changes only; no remote-only commits | Review, stage only the approved paths, commit, then `git push origin <branch>`. |70 | Local and remote have both advanced on the default branch | Stop for an explicit integration decision. Prefer moving the local work to a feature branch and using a PR; never force-push shared history. |71 | Feature branch needs current base | Fetch, then merge the base into the feature branch for a normal push, or rebase only with explicit authorization and a `--force-with-lease` plan. |72 | Conflicts, detached HEAD, missing remote, or protection failure | Do not guess a resolution. Report the exact state and smallest next action. |7374 Do not use a bare `git pull` because its merge/rebase behavior is host75 configuration-dependent. Use `--ff-only` for a pure update and an explicit76 merge or rebase decision for divergence.77785. For work that belongs on a non-default branch, push that branch and create79 or update a pull request targeting the verified base. A squash merge is a80 pull-request action, not a substitute for reconciling a rejected push.81 Immediately before an approved merge, verify the PR head SHA, target branch,82 approvals, and required checks. Merge only when the user authorizes that83 exact PR and strategy.84856. After every successful integration, fetch again and prove the result:8687 ```bash88 git fetch origin89 git status --short --branch90 git rev-list --left-right --count HEAD...<base-ref>91 git log -1 --oneline <base-ref>92 ```9394 A clean status alone is insufficient: report the pushed or merged commit95 SHA, the verified target ref, and whether local `HEAD` matches the intended96 remote ref. Run the project's relevant validation before claiming an app97 change is ready.9899## GitHub capability adapter100101When the host exposes a connected GitHub capability, use the connection the102user has made available to inspect repository metadata, compare commits, read103PR/check state, create or update a PR, and perform an explicitly approved104merge. Confirm that the connector's repository and account match the local105`origin` before any write.106107Do not embed a connector ID, token, or account name in this portable package.108Those are host- and user-specific. If the connector is unavailable, perform109local Git inspection and hand back the exact PR or merge action that requires a110connected GitHub surface.111112## PUSH_REJECTED recovery113114For the common error "the remote has commits that are not in the local115repository":1161171. Preserve the working tree; do not reset, stash-drop, or force-push.1182. Fetch `origin` and show the ahead/behind counts and commit subjects.1193. If the checkout is merely behind and clean, fast-forward it.1204. If the checkout has local commits as well, identify whether they are on the121 default branch or a feature branch and use the decision table above.1225. Resolve only user-approved conflicts. If this workflow started the merge or123 rebase and no subsequent user edits occurred, aborting that operation is a124 safe recovery option; otherwise stop and preserve the state for review.1256. Push normally, then re-fetch and verify the remote contains the expected126 commit. A second rejection means stop and re-inspect rather than escalating127 to a force push.128129## Output contract130131Return:132133- verified repository root, `origin` URL, current branch, and base ref;134- working-tree and ahead/behind state before any write;135- reviewed commit scope and every commit, push, PR, or merge actually made;136- the connector state used, or why hosted actions were not available;137- conflict/protection/authorization blockers and the smallest safe next step;138- post-action `git status`, target-ref comparison, commit SHA, and relevant139 validation result.140141## About142143Built by [Jamie Hill](https://overkillhill.com) · [OverKill Hill P³](https://overkillhill.com)144Published at [github.com/OKHP3](https://github.com/OKHP3)145Part of the [OKHP3/skillz](https://github.com/OKHP3/skillz) Agent Skill library.146MIT License -- free to use, fork, and adapt. A nod to the source is appreciated.