← 返回 Skills 市场
orbisz

git-publish

作者 orbisz · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
35
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install git-publish-skill
功能描述
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...
使用说明 (SKILL.md)

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.

  1. 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.

  2. Compare the current working directory (the project the user wants to push) against the keys in the mapping.

  3. If a mapping is found: Use the stored URL. Tell the user: "检测到该项目对应的仓库:\x3CURL>,直接使用。"

  4. 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.git
    • https://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:

  1. Run git init
  2. Run git add . to stage all files
  3. Run git commit -m "Initial commit"
  4. Run git remote add origin \x3CURL> to add the remote
  5. Run git branch -M \x3Ccurrent-branch> to rename to the detected branch name

If already a Git repository:

  1. Check if a remote named origin already 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 origin exists, run git remote add origin \x3CURL>

Step 3: Handle uncommitted changes

Check for uncommitted changes with git status --porcelain.

If there are uncommitted changes:

  1. Run git diff --cached to see staged changes
  2. Run git diff to see unstaged changes
  3. Stage all changes: git add .
  4. 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
  5. Run git commit -m "\x3Cgenerated message>"

If there are no uncommitted changes: Proceed directly to push.

Step 4: Push to GitHub

  1. Detect the current branch: git branch --show-current
  2. Try normal push first: git push -u origin \x3Cbranch>
  3. 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 origin to 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:
    • If the remote is already using SSH and the connection fails, retry up to 3 times, then report the error to the user.
  4. 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

Step 5: Save the mapping and confirm success

After a successful push:

  1. Save the mapping — Update references/repo-map.json to 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.

  2. 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:

  1. Evaluate whether the output achieved the intended goal: pass / fail.
  2. If it fails, reflect on the cause of failure and append a “failure case + improvement suggestion” to diary/YYYY-MM-DD.md.
  3. 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.
安全使用建议
Review carefully before installing. Only use it in repositories where you are comfortable staging all files, committing local changes, and pushing to GitHub. Check for secrets and private files first, avoid force-push unless you understand the remote-history impact, and remove or disable the repo-map and self-evolution diary behavior if you do not want persistent local path, repository, or execution-detail records.
能力评估
Purpose & Capability
Publishing to GitHub is the stated purpose, but the workflow includes high-impact actions: git init, staging all files, committing, pushing to a remote, optional force-push, persistent repo mapping, and a self-evolution mechanism unrelated to publishing.
Instruction Scope
The trigger is broad and the workflow does not require a clear preview-and-confirm step before staging all files, committing, pushing project contents, or saving metadata.
Install Mechanism
Installation is ordinary git-clone placement into supported skill directories; no executable installer or dependency package is present.
Credentials
Git and GitHub access are expected for this skill, but automatically adding all files and uploading repository contents can expose secrets or private work if invoked casually.
Persistence & Privilege
The skill updates a persistent repo-map file with absolute project paths and remote URLs, and also instructs runtime diary logging plus potential PRs to modify its own SKILL.md.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install git-publish-skill
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /git-publish-skill 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
feat: add self-evolution mechanism and new repo mappings
元数据
Slug git-publish-skill
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

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。

💬 留言讨论