/install git-publish-skill
Git Publish
Push the current project to a GitHub remote repository with a single workflow.
Workflow
Follow these steps in order:
Step 1: Resolve the remote URL
Before doing anything else, determine the GitHub repository URL.
-
Read the repo mapping file at
references/repo-map.json(relative to this skill's directory). This file maps local project paths to their GitHub URLs. -
Compare the current working directory (the project the user wants to push) against the keys in the mapping.
-
If a mapping is found: Use the stored URL. Tell the user: "检测到该项目对应的仓库:\x3CURL>,直接使用。"
-
If no mapping is found: Ask the user to provide the GitHub repository URL. Accept formats like:
https://github.com/user/repo.git[email protected]:user/repo.githttps://github.com/user/repo
If the user hasn't provided a URL yet, ask: "请提供GitHub仓库地址(例如 https://github.com/user/repo.git):"
Step 2: Check and initialize Git if needed
Run git status to check if the current directory is a Git repository.
If NOT a Git repository:
- Run
git init - Run
git add .to stage all files - Run
git commit -m "Initial commit" - Run
git remote add origin \x3CURL>to add the remote - Run
git branch -M \x3Ccurrent-branch>to rename to the detected branch name
If already a Git repository:
- Check if a remote named
originalready exists:- Run
git remote get-url origin - If the URL differs from what the user provided, ask the user whether to update it
- If no remote
originexists, rungit remote add origin \x3CURL>
- Run
Step 3: Handle uncommitted changes
Check for uncommitted changes with git status --porcelain.
If there are uncommitted changes:
- Run
git diff --cachedto see staged changes - Run
git diffto see unstaged changes - Stage all changes:
git add . - Analyze the staged changes and generate a commit message by summarizing the diff. The commit message should:
- Follow conventional commit format:
type(scope): brief summary - Types:
feat(new feature),fix(bug fix),chore(maintenance),docs,refactor,style,test - Title no more than 50 characters
- Body lists the affected files and what changed
- Follow conventional commit format:
- Run
git commit -m "\x3Cgenerated message>"
If there are no uncommitted changes: Proceed directly to push.
Step 4: Push to GitHub
- Detect the current branch:
git branch --show-current - Try normal push first:
git push -u origin \x3Cbranch> - If the push fails with a connection error (e.g., "Could not connect to server", "Failed to connect", timeout, network unreachable), check if the remote URL uses HTTPS protocol:
- Run
git remote get-url originto inspect the current URL. - If the URL starts with
https://, retry up to 3 times with a short pause between retries. - If all 3 HTTPS retries fail, automatically switch the remote to SSH:
- Convert the URL:
https://github.com/user/repo.git→[email protected]:user/repo.git - Run
git remote set-url origin [email protected]:user/repo.git - Try pushing again with SSH.
- Convert the URL:
- If the remote is already using SSH and the connection fails, retry up to 3 times, then report the error to the user.
- Run
- If the push fails for other reasons (e.g., divergent histories, non-fast-forward), present the error to the user and ask: "普通推送失败,是否使用强制推送?这可能会覆盖远程仓库的历史。(y/n)"
- If user agrees:
git push -u origin \x3Cbranch> --force - If user declines: stop and report the situation
- If user agrees:
Step 5: Save the mapping and confirm success
After a successful push:
-
Save the mapping — Update
references/repo-map.jsonto record the current project path and its GitHub URL, so future pushes for this project won't need to ask for the URL again. Read the file, add or update the entry, and write it back. The key is the absolute path of the project directory, the value is the remote URL. -
Confirm success — Report:
- The remote URL
- The branch that was pushed
- The commit message(s) that were pushed
Reference files
references/repo-map.json— Local path to GitHub URL mappings. Read this first to resolve the remote URL; update it after each successful push.
Self-Evolution Mechanism
After each execution of this Skill:
- Evaluate whether the output achieved the intended goal: pass / fail.
- If it fails, reflect on the cause of failure and append a “failure case + improvement suggestion” to
diary/YYYY-MM-DD.md. - If a certain improvement suggestion is repeatedly mentioned in the most recent three executions, refine it into a formal rule and submit a PR to modify this
SKILL.md.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install git-publish-skill - 安装完成后,直接呼叫该 Skill 的名称或使用
/git-publish-skill触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
git-publish 是什么?
Publish the current project to a GitHub remote repository. Use this skill whenever the user wants to push code to GitHub, publish to a remote, upload a proje... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 35 次。
如何安装 git-publish?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install git-publish-skill」即可一键安装,无需额外配置。
git-publish 是免费的吗?
是的,git-publish 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
git-publish 支持哪些平台?
git-publish 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 git-publish?
由 orbisz(@orbisz)开发并维护,当前版本 v1.0.0。