Home / Market / private-github-repo-upload

private-github-repo-upload

Safely initialize, sanitize, commit, create, and push a local project with private runtime data to a separate private GitHub repository. Use when the user asks to back up or upload a local data-bearing project to a private GitHub repo while keeping public Skills separate. Never uploads credentials, environments, caches, or public Skill source.

skill★ 00 dlclawhubMIT-0Install in CosmosUpstream Source

Documentation & Preview

--- name: private-github-repo-upload description: "Safely initialize, sanitize, commit, create, and push a local project with private runtime data to a separate private GitHub repository. Use when the user asks to back up or upload a local data-bearing project to a private GitHub repo while keeping public Skills separate. Never uploads credentials, environments, caches, or public Skill source." description_zh: "安全上传私有项目到 GitHub" description_en: "Secure private GitHub upload" version: "1.1.3" disable: false agent_created: true read_when:

not_for:

---

Private GitHub Repository Upload

Use this as a fixed, auditable workflow. It is a Workflow, not an autonomous discovery agent: project scope, exclusion policy, and repository name must be explicit or use a documented default confirmed by the user.

Workflow

Step 1: [Deterministic] Confirm scope

Step 2: [Deterministic] Inspect and define exclusions

Step 3: [Deterministic] Initialize and stage safely

Step 4: [Deterministic] Commit locally

Step 5: [Deterministic] Create or reuse the private remote

Step 6: [Deterministic] Push without persisting credentials

Step 6B: [Deterministic] Manual push via the Git Data API

Use git/blobs → git/trees → git/commits → PATCH git/refs/heads/<branch> to advance the remote. Four constraints are mandatory; violating any of them produces a silently divergent history rather than an error:

  1. base_tree must be the REMOTE commit's tree. A local tree oid does not exist on the remote and returns 422 base_tree is not a valid tree oid.
  2. Pass the local commit's full author/committer metadata, with the local UTC offset preserved. GitHub writes the date as +0000 when omitted. If the local commit is +0800, the commit objects differ byte-for-byte and the remote SHA diverges from the local one — the histories look equivalent (identical tree) but fork permanently. Convert git raw 1788157141 +0800 to local wall-clock ISO 2026-08-31T14:19:01+08:00.
  3. Extract the message with git cat-file commit HEAD and take everything after the first blank line. git log -1 --format=%B plus .trim() drops the trailing newline and changes the SHA.
  4. Read changed files with git -c core.quotePath=false diff-tree .... Without it, CJK paths are escaped to "reports/601985_\345\255\243..." and fs.existsSync fails on every one of them.

After creating the commit, assert remote_commit.sha === local_head_sha before advancing the ref. If they differ, do not push — fix the metadata first.

If a divergent commit was already pushed, do not force-reset or force-push to rewrite the remote — Hard Rule 5 forbids it regardless of who created the commit. Recover without rewriting history: rebuild the intended tree from API metadata and advance the branch with a new forward commit (a git revert of the bad change, or a corrected commit through the normal PATCH-ref path with force: false). If the remote tip is not the one you expect, or the commit may be shared, stop and report the divergence for explicit user approval — never assume nobody else is based on it. Any exception requires explicit approval, preserving the current remote tip and an atomic expected-SHA check that aborts if the remote changed.

Step 7: [Deterministic] Verify remote state

  1. Raw-byte blob SHA: compute sha1("blob " + byteLength + "\0" + rawFileBytes) in Node/Python on the local file, and compare it to the sha of that path's entry in the remote git/trees/<sha>?recursive=1. If they match, the file is byte-identical on the remote.
  2. Contents API decode: GET /repos/{owner}/{repo}/contents/<path>?ref=<remote-sha>, base64-decode content, and compare to the local file bytes (or grep for a known unique substring). This is the most reliable end-to-end check.

Hard Rules

  1. Public Skills and private runtime data remain separate repositories.
  2. Never commit or print GitHub, Notion, webhook, cloud, database, or other credentials.
  3. Never upload a home directory, Desktop, Downloads, Documents, or broad personal directory as a project.
  4. Never use git add before the exclusion policy is established and inspected.
  5. Never use force-push, destructive reset, or remote deletion in this workflow.
  6. Private repository status must be verified through the authenticated API; a successful push alone is not proof of privacy.
  7. A 404/422 or network error must not be treated as a final diagnosis after one request; retry and cross-check first.
  8. If the staged scan finds a real secret, stop the upload, remove it from the index and history before any push, and rotate the exposed credential when applicable.

Pitfalls