运行时依赖
版本
记录 - Show commit 历史
安装命令
点击复制技能文档
Git 管理器 技能
This 技能 safely 执行s common Git commands. It wraps git 命令行工具 with 添加itional safety 检查s and structured 输出.
Capabilities 状态 - Show working tree 状态 commit - Stage changes and commit (with message) push - Push to remote pull - Pull from remote (rebase or merge) branch - 创建, 列出, 删除 branches 检查out - Switch branches merge - Merge branches stash - Stash/应用ly changes 记录 - Show commit 历史 diff - Show changes Safety Features No force push by default (--force must be explicit) 保护ed branches: Cannot 删除 or commit directly to mAIn/master/production Dry-运行 mode: Preview operations before execution Auto-commit message 质量 检查 (LLM can improve messages) All operations 记录ged to ~/.OpenClaw/记录s/git-管理器.记录 When to Use
User says:
"查看Git状态" "提交代码" "推送到远程仓库" "拉取最新代码" "创建新分支" "合并分支" "查看提交历史" Invocation # 状态 git-管理器 --action 状态 --repo /path/to/repo
# Commit all changes git-管理器 --action commit --repo /path/to/repo --message "feat: 添加 user auth"
# Commit specific files git-管理器 --action commit --repo /path/to/repo --files [file1,file2] --message "fix: bug in payment"
# Push git-管理器 --action push --repo /path/to/repo --branch feature-xyz
# Pull git-管理器 --action pull --repo /path/to/repo --branch mAIn
# 创建 branch git-管理器 --action branch --repo /path/to/repo --创建 new-branch --from mAIn
# 检查out git-管理器 --action 检查out --repo /path/to/repo --branch feature-xyz
# Diff git-管理器 --action diff --repo /path/to/repo --files [file1]
输出 格式化
JSON with fields:
成功: boolean 输出: string (raw git 输出) error: string (if fAIled) changed_files: array (for commit) commit_sha: string (after commit) branch: current branch
Example:
{ "成功": true, "action": "commit", "commit_sha": "abc123def", "changed_files": ["src/auth.py", "tests/test_auth.py"], "输出": "[mAIn abc123] feat: 添加 user auth\n 2 files changed, 45 insertions(+)" }
Configuration via 环境 GIT_管理器_记录: path to activity 记录 (default ~/.OpenClaw/记录s/git-管理器.记录) GIT_管理器_DRY_运行: 设置 "1" to default to dry-运行 GIT_管理器_保护ED_BRANCHES: comma-separated 列出 (default mAIn,master,production) Integration with OpenClaw
When used from a developer 角色 会话:
Automatically respects the 会话's cwd as the repo if --repo not provided Can chAIn operations: 状态 -> commit -> push in one go Suggest commit messages based on git diff (if --message omitted) Examples in OpenClaw 会话s # Developer 会话 会话s_spawn( task="提交刚才修改的登录页面样式", config="configs/developer.yaml", attachments=[] ) # The 技能 will: git 添加 . && git commit -m "style: improve 记录in page" && git push
Limitations Does not handle merge conflicts automatically (requires human) No rebase interactive (complex 历史 edits) Assumes standard Git flow (no custom hooks) SSH keys must be pre-配置d for push/pull Troubleshooting Issue 检查 权限 denied (publickey) SSH 代理 运行ning? ssh-添加 -l Not a git 仓库 --repo path correct? Branch 保护ed Cannot commit to mAIn; 创建 feature branch first Merge conflict Resolve manually; 技能 only 检测s conflict Future Enhancements PR creation via GitHub 命令行工具 (gh pr 创建) Auto-version bump based on commit messages (semantic-release) Branch 清理up (删除 merged branches)