agentleFS
OpenGHzOpenGHz/AgentSkills/git-fork-remote/SKILL.md

git-fork-remote

Skill1 starsChanged 6 months agoMITView on GitHub

Configure Git remotes for a fork workflow. Use when user says \"add my fork\", \"set origin upstream\", \"fork remote\", \"git remote\", \"upstream remote\", \"像 origin/upstream 这样\", or wants origin to point to their fork and upstream to the original repository.

  • Commits and pushes

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 10 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when the user wants a remote layout like:

    line 18
  2. Distinctive:

    Run from the repository root:

    line 47
  3. Distinctive:

    If not inside a Git repository, stop and tell the user to run the skill from the repository root or provide the correct path.

    line 60
  4. Distinctive:

    Use this decision table:

    line 64
  5. Distinctive:

    Never delete or overwrite a remote URL without first preserving it or confirming that it is redundant.

    line 75
  6. Very specific:

    Prefer explicit git remote commands over complex shell conditionals.

    line 79
  7. Very specific:

    If origin does not exist:

    line 91
  8. Very specific:

    If origin already points to the fork and only upstream is missing:

    line 99
  9. Very specific:

    Use git -C <repo-path> if the active terminal may not be in the repository root.

    line 106
  10. Very specific:

    No command is left waiting at a shell continuation prompt such as then>.

    line 121
  11. Distinctive:

    Do not run git push, git pull, git fetch, or network-mutating commands unless the user asks.

    line 139
  12. Distinctive:

    Do not change branches, reset, rebase, or edit files as part of this skill.

    line 140
  13. Distinctive:

    If Git asks for credentials or a token, do not collect secrets in chat.

    line 141
  14. Distinctive:

    If a command enters a continuation prompt, cancel or kill that terminal and retry with simpler one-line commands.

    line 142
  15. Distinctive:

    Treat remote URL changes as reversible but still important: show the before/after mapping when the user needs auditability.

    line 143

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Fork Remote Setup

Configure a repository to use the standard fork layout:

  • origin points to the user's fork and is the default push target.
  • upstream points to the original repository and is used for syncing changes.
  • Redundant temporary remotes such as fork are removed after migration.

When to Use

Use this skill when the user wants a remote layout like:

origin    https://github.com/<user>/<fork>.git
upstream  https://github.com/<owner>/<original>.git

Typical requests:

  • "帮我添加我 fork 的远程链接"
  • "我希望 remote 是 origin 指向我的 fork,upstream 指向原仓库"
  • "把 fork 改成 origin,把原来的 origin 改成 upstream"
  • "set up git remotes for my fork"

Inputs

Required:

  • Fork URL, usually a GitHub HTTPS or SSH URL.

Optional:

  • Upstream URL. If omitted, preserve the current origin URL as upstream.
  • Preferred fork remote name. Default is origin; only use another name if the user explicitly asks.

Procedure

1. Inspect Current Remotes

Run from the repository root:

git remote -v

Identify:

  • Current origin URL.
  • Whether upstream already exists.
  • Whether a temporary fork remote already exists.
  • Whether the current directory is actually inside a Git repository.

If not inside a Git repository, stop and tell the user to run the skill from the repository root or provide the correct path.

2. Decide Target Mapping

Use this decision table:

Current StateAction
origin points to original repo, fork URL suppliedSave current origin URL as upstream, then set origin to fork URL
fork remote points to fork URL, origin points to original repoSet origin to fork URL, set upstream to old origin, remove fork
upstream exists and matches original repoKeep it and set origin to fork URL
upstream exists but conflicts with the old origin or supplied upstream URLAsk before overwriting unless the user explicitly requested replacement
No origin existsAdd origin as fork URL; ask for upstream URL if not supplied
Fork URL equals current originDo not change origin; ensure upstream is configured if possible

Never delete or overwrite a remote URL without first preserving it or confirming that it is redundant.

3. Apply Safe Remote Changes

Prefer explicit git remote commands over complex shell conditionals. Avoid multi-line if commands in terminals that may be sensitive to quoting or continuation prompts.

Recommended command sequence when current origin is the original repository:

original_url=$(git remote get-url origin)
git remote set-url origin <fork-url>
git remote add upstream "$original_url" 2>/dev/null || git remote set-url upstream "$original_url"
git remote remove fork 2>/dev/null || true
git remote -v

If origin does not exist:

git remote add origin <fork-url>
git remote add upstream <upstream-url>
git remote -v

If origin already points to the fork and only upstream is missing:

git remote add upstream <upstream-url>
git remote -v

Use git -C <repo-path> if the active terminal may not be in the repository root.

4. Verify Final Layout

Always finish with:

git remote -v

Completion criteria:

  • origin fetch and push URLs both equal the user's fork URL.
  • upstream fetch and push URLs both equal the original repository URL.
  • Temporary fork remote is absent unless the user explicitly asked to keep it.
  • No command is left waiting at a shell continuation prompt such as then>.

Report the final remote mapping concisely:

origin    <fork-url>
upstream  <original-url>

Then suggest common follow-up commands:

git push origin main
git fetch upstream

Safety Rules

  • Do not run git push, git pull, git fetch, or network-mutating commands unless the user asks.
  • Do not change branches, reset, rebase, or edit files as part of this skill.
  • If Git asks for credentials or a token, do not collect secrets in chat; ask the user to type them directly into the terminal.
  • If a command enters a continuation prompt, cancel or kill that terminal and retry with simpler one-line commands.
  • Treat remote URL changes as reversible but still important: show the before/after mapping when the user needs auditability.

Example

User request:

帮我添加我 fork 的远程链接:https://github.com/OpenGHz/project.git,我希望 origin 是我的 fork,upstream 是原仓库。

Expected outcome:

origin    https://github.com/OpenGHz/project.git
upstream  https://github.com/original-owner/project.git

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.