GitHub Repo Sync
Use this skill when the user wants to upload a local project to GitHub, bind a local repo to a GitHub remote, or keep a repo in sync with GitHub.
This skill is especially useful on this machine because GitHub HTTPS may reset mid-connection, while SSH authentication is available and can be routed through port 443 when needed.
Core Workflow
- Inspect local repo state first.
- Check whether the target folder is already a git repo.
- Check branch, remotes, working tree status, and git user identity before changing anything.
- Prepare local history.
- If the folder is not yet a repo, initialize git.
- Make sure there is at least one local commit before the first push.
- For shareable repos, remove obvious caches, outputs, cookies, tokens, and local-only runtime state before committing.
- Connect the GitHub remote safely.
- Add or update
origin rather than creating duplicate remotes.
- Use
scripts/set-github-remote.ps1 when you want a deterministic helper for this step.
- Prefer the safest transport that works.
- HTTPS is acceptable when stable.
- If GitHub HTTPS fails with connection resets on this machine, switch to SSH.
- If port 22 is blocked or unreliable, use GitHub SSH over port 443.
- Use
scripts/ensure-github-ssh-443.ps1 to append the github.com -> ssh.github.com:443 host rule when needed.
- Fetch before pushing.
- Always inspect the remote branch before the first push to a repo you did not create in this session.
- If the remote contains a GitHub-created initial commit such as
LICENSE or .gitignore, fetch and merge it instead of force-pushing over it.
- If local and remote histories are unrelated, prefer
git merge origin/main --allow-unrelated-histories --no-edit after inspecting the remote content.
- Push and verify.
- Push with upstream tracking:
git push -u origin <branch>.
- Confirm the push succeeded and that the local branch tracks the remote branch.
Safety Rules
- Never force-push unless the user explicitly asks for it.
- Never overwrite or discard remote initialization commits without inspecting them first.
- Never push secrets, cookies, tokens,
.env files, browser session state, or obvious machine-local caches unless the user explicitly wants that.
- If a repo is dirty with unrelated user changes, work with them or stop and confirm, rather than sweeping them away.
- If GitHub authentication is missing, stop and tell the user exactly which auth step is blocking progress.
Machine Notes
gh may be unavailable on this machine. Do not depend on GitHub CLI unless you verify it exists first.
- GitHub HTTPS may fail with
Recv failure: Connection was reset. Treat that as a transport problem, not necessarily a bad repo URL.
- SSH authentication is available locally and can be validated with:
ssh -T git@github.com
- If needed, GitHub SSH over 443 can be validated with:
ssh -T -p 443 git@ssh.github.com
Helpers
This skill includes two low-risk local helpers:
scripts/ensure-github-ssh-443.ps1
Ensures ~/.ssh/config contains a Host github.com block that routes through ssh.github.com on port 443.
scripts/set-github-remote.ps1
Initializes a repo if needed, then safely adds or updates a remote such as origin.
Use these helpers for setup steps, then continue with normal git commands for fetch, merge, commit, and push.
Common Flows
Publish a local folder to a new GitHub repo
- Inspect local status.
- Initialize git if needed.
- Add
.gitignore / README / share-safe structure if appropriate.
- Commit locally.
- Set
origin.
- Fetch remote.
- Merge any remote initialization commit if present.
- Push
main.
Sync an existing local repo to GitHub
- Check status and remotes.
- Fetch
origin.
- Review divergence before merging or pushing.
- Push only after confirming local changes are ready.
Publish a skill pack
When the repository is meant to share Codex skills:
- Prefer
skills/<skill-name>/... layout.
- Include a concise repo-level
README.md.
- Add install commands that use Codex's
skill-installer.
- Keep runtime caches such as
node_modules, tmp/, output/, and browser session state out of git.
References
Read references/common-flows.md for reusable command sequences and error-handling patterns.
1---2name: github-repo-sync3description: Publish or sync a local folder or repository to GitHub. Use when Codex needs to initialize git, prepare a repo for GitHub sharing, connect or update the `origin` remote, switch from unstable GitHub HTTPS to SSH over 443 on this machine, fetch and merge remote initialization commits safely, or push ongoing local changes without force-pushing user work.4---56# GitHub Repo Sync78Use this skill when the user wants to upload a local project to GitHub, bind a local repo to a GitHub remote, or keep a repo in sync with GitHub.910This skill is especially useful on this machine because GitHub HTTPS may reset mid-connection, while SSH authentication is available and can be routed through port 443 when needed.1112## Core Workflow13141. Inspect local repo state first.15 - Check whether the target folder is already a git repo.16 - Check branch, remotes, working tree status, and git user identity before changing anything.172. Prepare local history.18 - If the folder is not yet a repo, initialize git.19 - Make sure there is at least one local commit before the first push.20 - For shareable repos, remove obvious caches, outputs, cookies, tokens, and local-only runtime state before committing.213. Connect the GitHub remote safely.22 - Add or update `origin` rather than creating duplicate remotes.23 - Use `scripts/set-github-remote.ps1` when you want a deterministic helper for this step.244. Prefer the safest transport that works.25 - HTTPS is acceptable when stable.26 - If GitHub HTTPS fails with connection resets on this machine, switch to SSH.27 - If port 22 is blocked or unreliable, use GitHub SSH over port 443.28 - Use `scripts/ensure-github-ssh-443.ps1` to append the `github.com -> ssh.github.com:443` host rule when needed.295. Fetch before pushing.30 - Always inspect the remote branch before the first push to a repo you did not create in this session.31 - If the remote contains a GitHub-created initial commit such as `LICENSE` or `.gitignore`, fetch and merge it instead of force-pushing over it.32 - If local and remote histories are unrelated, prefer `git merge origin/main --allow-unrelated-histories --no-edit` after inspecting the remote content.336. Push and verify.34 - Push with upstream tracking: `git push -u origin <branch>`.35 - Confirm the push succeeded and that the local branch tracks the remote branch.3637## Safety Rules3839- Never force-push unless the user explicitly asks for it.40- Never overwrite or discard remote initialization commits without inspecting them first.41- Never push secrets, cookies, tokens, `.env` files, browser session state, or obvious machine-local caches unless the user explicitly wants that.42- If a repo is dirty with unrelated user changes, work with them or stop and confirm, rather than sweeping them away.43- If GitHub authentication is missing, stop and tell the user exactly which auth step is blocking progress.4445## Machine Notes4647- `gh` may be unavailable on this machine. Do not depend on GitHub CLI unless you verify it exists first.48- GitHub HTTPS may fail with `Recv failure: Connection was reset`. Treat that as a transport problem, not necessarily a bad repo URL.49- SSH authentication is available locally and can be validated with:5051```powershell52ssh -T git@github.com53```5455- If needed, GitHub SSH over 443 can be validated with:5657```powershell58ssh -T -p 443 git@ssh.github.com59```6061## Helpers6263This skill includes two low-risk local helpers:6465- `scripts/ensure-github-ssh-443.ps1`66 Ensures `~/.ssh/config` contains a `Host github.com` block that routes through `ssh.github.com` on port 443.67- `scripts/set-github-remote.ps1`68 Initializes a repo if needed, then safely adds or updates a remote such as `origin`.6970Use these helpers for setup steps, then continue with normal git commands for fetch, merge, commit, and push.7172## Common Flows7374### Publish a local folder to a new GitHub repo75761. Inspect local status.772. Initialize git if needed.783. Add `.gitignore` / README / share-safe structure if appropriate.794. Commit locally.805. Set `origin`.816. Fetch remote.827. Merge any remote initialization commit if present.838. Push `main`.8485### Sync an existing local repo to GitHub86871. Check status and remotes.882. Fetch `origin`.893. Review divergence before merging or pushing.904. Push only after confirming local changes are ready.9192### Publish a skill pack9394When the repository is meant to share Codex skills:9596- Prefer `skills/<skill-name>/...` layout.97- Include a concise repo-level `README.md`.98- Add install commands that use Codex's `skill-installer`.99- Keep runtime caches such as `node_modules`, `tmp/`, `output/`, and browser session state out of git.100101## References102103Read `references/common-flows.md` for reusable command sequences and error-handling patterns.