Install
openclaw skills install git-publish-skillPublish 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 project to GitHub, set up remote tracking, or says things like "push to github", "publish this repo", "上传到GitHub", "推送到GitHub". This skill handles git initialization, remote setup, auto-commit of uncommitted changes, and pushing.
openclaw skills install git-publish-skillPush the current project to a GitHub remote repository with a single workflow.
Follow these steps in order:
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: "检测到该项目对应的仓库:<URL>,直接使用。"
If no mapping is found: Ask the user to provide the GitHub repository URL. Accept formats like:
https://github.com/user/repo.gitgit@github.com:user/repo.githttps://github.com/user/repoIf the user hasn't provided a URL yet, ask: "请提供GitHub仓库地址(例如 https://github.com/user/repo.git):"
Run git status to check if the current directory is a Git repository.
If NOT a Git repository:
git initgit add . to stage all filesgit commit -m "Initial commit"git remote add origin <URL> to add the remotegit branch -M <current-branch> to rename to the detected branch nameIf already a Git repository:
origin already exists:
git remote get-url originorigin exists, run git remote add origin <URL>Check for uncommitted changes with git status --porcelain.
If there are uncommitted changes:
git diff --cached to see staged changesgit diff to see unstaged changesgit add .type(scope): brief summaryfeat (new feature), fix (bug fix), chore (maintenance), docs, refactor, style, testgit commit -m "<generated message>"If there are no uncommitted changes: Proceed directly to push.
git branch --show-currentgit push -u origin <branch>git remote get-url origin to inspect the current URL.https://, retry up to 3 times with a short pause between retries.https://github.com/user/repo.git → git@github.com:user/repo.gitgit remote set-url origin git@github.com:user/repo.gitgit push -u origin <branch> --forceAfter a successful push:
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.
Confirm success — Report:
references/repo-map.json — Local path to GitHub URL mappings. Read this first to resolve the remote URL; update it after each successful push.After each execution of this Skill:
diary/YYYY-MM-DD.md.SKILL.md.