GitHub Sync
Trigger Announcement
When this skill triggers, say one short line like: "Let me check the git environment first according to the github-sync skill..."
Step 1: Environment Detection
Run these 5 checks before any operation:
- Has .git? -> git rev-parse --is-inside-work-tree 2>$null
- Has remote origin? -> git remote -v
- Working tree clean? -> git status --porcelain
- Default branch? -> git ls-remote --symref origin HEAD (skip if no remote)
- Proxy configured? -> git config http.proxy
After checks, match scenario and choose push or pull flow.
Proxy Config
User proxy: http://127.0.0.1:7892
If not set:
git config http.proxy http://127.0.0.1:7892
git config https.proxy http://127.0.0.1:7892
For npm, set env vars:
$env:HTTP_PROXY="http://127.0.0.1:7892"
$env:HTTPS_PROXY="http://127.0.0.1:7892"
Branch Detection
main vs master: same thing, different default name. Detect: git ls-remote --symref origin HEAD if remote exists. If no remote (new repo): default to master unless user specifies another.
Push to GitHub
Match scenario from references/push-scenarios.md after detection.
Pull / Clone from GitHub
Match scenario from references/pull-scenarios.md after detection.
Conflict Handling
If pull/push has conflicts:
- Try git merge --no-edit for auto-merge
- If fails, check conflict files, use git add to mark resolved
- Or git merge --abort to roll back
- If local changes unimportant, stash or reset first
Auth
If auth fails: tell user they need GitHub authentication. Recommend gh auth login (GitHub CLI) or SSH key.