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
In this repository4 other files it gives its agents.
- git-upstream-rebaseSkill
- pixiSkill
- process-recordSkill
- update-project-docsSkill
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
- Distinctive: line 18
Use this skill when the user wants a remote layout like:
- Distinctive: line 47
Run from the repository root:
- Distinctive: line 60
If not inside a Git repository, stop and tell the user to run the skill from the repository root or provide the correct path.
- Distinctive: line 64
Use this decision table:
- Distinctive: line 75
Never delete or overwrite a remote URL without first preserving it or confirming that it is redundant.
- Very specific: line 79
Prefer explicit git remote commands over complex shell conditionals.
- Very specific: line 91
If origin does not exist:
- Very specific: line 99
If origin already points to the fork and only upstream is missing:
- Very specific: line 106
Use git -C <repo-path> if the active terminal may not be in the repository root.
- Very specific: line 121
No command is left waiting at a shell continuation prompt such as then>.
- Distinctive: line 139
Do not run git push, git pull, git fetch, or network-mutating commands unless the user asks.
- Distinctive: line 140
Do not change branches, reset, rebase, or edit files as part of this skill.
- Distinctive: line 141
If Git asks for credentials or a token, do not collect secrets in chat.
- Distinctive: line 142
If a command enters a continuation prompt, cancel or kill that terminal and retry with simpler one-line commands.
- Distinctive: line 143
Treat remote URL changes as reversible but still important: show the before/after mapping when the user needs auditability.
≈ “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.
Files
Git Fork Remote Setup
Configure a repository to use the standard fork layout:
originpoints to the user's fork and is the default push target.upstreampoints to the original repository and is used for syncing changes.- Redundant temporary remotes such as
forkare 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>.gitTypical 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
originURL asupstream. - 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 -vIdentify:
- Current
originURL. - Whether
upstreamalready exists. - Whether a temporary
forkremote 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 State | Action |
origin points to original repo, fork URL supplied | Save current origin URL as upstream, then set origin to fork URL |
fork remote points to fork URL, origin points to original repo | Set origin to fork URL, set upstream to old origin, remove fork |
upstream exists and matches original repo | Keep it and set origin to fork URL |
upstream exists but conflicts with the old origin or supplied upstream URL | Ask before overwriting unless the user explicitly requested replacement |
No origin exists | Add origin as fork URL; ask for upstream URL if not supplied |
Fork URL equals current origin | Do 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 -vIf origin does not exist:
git remote add origin <fork-url>
git remote add upstream <upstream-url>
git remote -vIf origin already points to the fork and only upstream is missing:
git remote add upstream <upstream-url>
git remote -vUse git -C <repo-path> if the active terminal may not be in the repository root.
4. Verify Final Layout
Always finish with:
git remote -vCompletion criteria:
originfetch and push URLs both equal the user's fork URL.upstreamfetch and push URLs both equal the original repository URL.- Temporary
forkremote 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 upstreamSafety 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.gitDoes 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
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.

