workspace-git-sync
将 OpenClaw workspace 目录(~/.openclaw/workspace/)同步到指定的本地 Git 仓库, 自动执行 git add、commit 和 push 操作。 使用场景: - 备份 workspace 文件到 Git 仓库 - 将工作目录同步到远程备份 - 定期归档 OpenClaw...
MIT-0 · Free to use, modify, and redistribute. No attribution required.
⭐ 1 · 32 · 0 current installs · 0 all-time installs
MIT-0
Security Scan
OpenClaw
Suspicious
medium confidencePurpose & Capability
The skill's name/description and its code align: it copies ~/.openclaw/workspace into a local Git repo, runs git add/commit/push, and can force-push. However the metadata declares no required binaries or primary credential even though the implementation calls out to the 'git' CLI (and the SKILL.md examples call 'python3'). The omission of 'git' and 'python3' as required binaries is an incoherence the user should note.
Instruction Scope
SKILL.md and the script stay within the stated scope: they validate the source directory, validate the target is a git repo, pull, wipe non-excluded files in the target, copy workspace contents, commit, and push. This is expected for a sync/backup tool. Important caveats: the script deletes non-excluded files in the target repo (preserving only .git) and will push whatever it copies (including any sensitive files present in the workspace). The tool also offers a 'force' strategy that skips pull and uses --force-with-lease; this is destructive by design and must be used with care.
Install Mechanism
There is no install spec (instruction-only skill with included script files). That is low risk from an installer perspective, but the README contains a placeholder clone URL (github.com/yourname) which suggests the source/maintainer is unclear. The code is present in the skill bundle and will be written to disk when the skill is installed/used.
Credentials
The skill declares no required environment variables or credentials (appropriate), but it relies on locally configured Git credentials/remote configuration to push data. That means data copied from your workspace can be transmitted to whatever remote is configured for the target repo (origin). You should verify the target repo's remote URL and that you trust it before running; the skill itself does not request keys but will use any existing git auth helpers or credentials on the host.
Persistence & Privilege
always:false (normal). The skill does not request permanent platform-wide privileges and does not modify other skills. It will write to the target git repo and set local git user.name/email inside that repo (expected and scoped). The default allow-autonomous-invocation is platform normal — not sufficient alone to raise a flag.
What to consider before installing
This skill appears to do what it says, but take these precautions before installing or running it: 1) Ensure Git and Python are available on the host (the metadata omits these requirements). 2) Inspect the bundle source/author (README clone URL is a placeholder), and review the included script locally before execution. 3) Before running, run a dry test: point the script at an empty test repo or a copy of the target to observe behavior. 4) Check the target repo's 'origin' remote URL — the script will push the workspace contents to that remote using your existing git credentials, so confirm you trust that remote. 5) Be aware the script deletes all non-excluded items in the target directory (preserves only .git) and can force-style push; back up the target repo first. 6) If you need a less-destructive workflow, request or modify the code to support a dry-run mode and safer defaults (no delete, no force).Like a lobster shell, security has layers — review code before you run it.
Current versionv1.0.0
Download ziplatest
License
MIT-0
Free to use, modify, and redistribute. No attribution required.
SKILL.md
Workspace Git Sync
将 OpenClaw 工作目录同步到 Git 仓库,实现自动备份和版本控制。
功能特性
- 自动排除:默认排除
skills/、__pycache__/、.clawhub/等 - Git 操作:自动执行 pull → copy → commit → push
- 冲突处理:同步前自动拉取远程变更
- 安全推送:使用
--force-with-lease而非--force
使用方法
基础用法
# 同步到指定 Git 仓库
python3 ~/.openclaw/workspace/skills/workspace-git-sync/scripts/sync_workspace.py ~/projects/backup-repo
# 带自定义提交信息
python3 ~/.openclaw/workspace/skills/workspace-git-sync/scripts/sync_workspace.py ~/projects/backup-repo "每日备份"
Python API
from scripts.sync_workspace import sync_workspace_to_git, quick_sync, force_sync
# 标准同步
result = sync_workspace_to_git("~/projects/backup-repo")
# 快速同步
result = quick_sync("~/projects/backup-repo", "快速备份")
# 强制同步(危险)
result = force_sync("~/projects/backup-repo", "强制覆盖")
参数说明
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
target_repo_path | str | 必需 | 目标 Git 仓库本地路径 |
branch | str | 自动检测 | 目标分支 |
commit_msg | str | 自动生成 | 提交信息 |
exclude_patterns | list | ["skills", ".git", ...] | 额外排除项 |
pull_before_push | bool | True | 推送前是否先 pull |
strategy | str | "rebase" | 合并策略 (rebase/merge/force) |
执行流程
- 检查源目录 — 验证
~/.openclaw/workspace/存在 - 检查目标仓库 — 验证是有效的 Git 仓库
- 拉取远程变更 —
git pull --rebase避免冲突 - 清理目标目录 — 删除旧文件(保留
.git/) - 复制文件 — 从 workspace 复制到目标目录
- 提交并推送 —
git add -A→git commit→git push
默认排除项
以下文件/目录会自动排除,不会同步:
skills/— 技能目录(通常很大).git/— Git 元数据__pycache__/— Python 缓存.DS_Store— macOS 系统文件node_modules/— Node.js 依赖.clawhub/— OpenClaw 缓存
使用示例
示例 1:基础同步
用户:将 workspace 同步到 ~/backup/openclaw
AI:执行 sync_workspace.py ~/backup/openclaw
示例 2:指定分支和提交信息
sync_workspace_to_git(
target_repo_path="~/github-pages",
branch="gh-pages",
commit_msg="Deploy workspace backup"
)
示例 3:强制同步(危险)
# 跳过 pull,直接强制推送
force_sync("~/projects/backup-repo", "Emergency update")
错误处理
| 错误场景 | 处理方式 |
|---|---|
| 源目录不存在 | 报错,检查 ~/.openclaw/workspace/ |
| 目标不是 Git 仓库 | 报错,提示初始化仓库:git init |
| 合并冲突 | 中止操作,提示手动解决 |
| 无推送权限 | 显示 Git 错误,检查权限或 Token |
脚本位置
~/.openclaw/workspace/skills/workspace-git-sync/
├── SKILL.md
└── scripts/
└── sync_workspace.py
注意事项
- 目标必须是 Git 仓库:文件夹必须包含
.git/目录 - 路径格式:支持
~展开(如~/projects/repo) - 数据安全:清理目标目录时会保留
.git/,不会丢失版本历史 - 权限要求:对目标目录有读写权限,对 Git 仓库有写权限
Files
3 totalSelect a file
Select a file to preview.
Comments
Loading comments…
