workspace-git-sync

将 OpenClaw workspace 目录(~/.openclaw/workspace/)同步到指定的本地 Git 仓库, 自动执行 git add、commit 和 push 操作。 使用场景: - 备份 workspace 文件到 Git 仓库 - 将工作目录同步到远程备份 - 定期归档 OpenClaw 工作数据 触发方式: - "将 workspace 同步到 /path/to/repo" - "备份 workspace 到 ~/projects/backup-repo" - "推送 workspace 到指定本地仓库"

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "workspace-git-sync" with this command: npx skills add david668haha/workspace-git-sync

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_pathstr必需目标 Git 仓库本地路径
branchstr自动检测目标分支
commit_msgstr自动生成提交信息
exclude_patternslist["skills", ".git", ...]额外排除项
pull_before_pushboolTrue推送前是否先 pull
strategystr"rebase"合并策略 (rebase/merge/force)

执行流程

  1. 检查源目录 — 验证 ~/.openclaw/workspace/ 存在
  2. 检查目标仓库 — 验证是有效的 Git 仓库
  3. 拉取远程变更git pull --rebase 避免冲突
  4. 清理目标目录 — 删除旧文件(保留 .git/
  5. 复制文件 — 从 workspace 复制到目标目录
  6. 提交并推送git add -Agit commitgit 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

注意事项

  1. 目标必须是 Git 仓库:文件夹必须包含 .git/ 目录
  2. 路径格式:支持 ~ 展开(如 ~/projects/repo
  3. 数据安全:清理目标目录时会保留 .git/,不会丢失版本历史
  4. 权限要求:对目标目录有读写权限,对 Git 仓库有写权限

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Img2img

Generate images from text descriptions using DALL-E 3 while adhering to usage policies and avoiding realistic human faces.

Registry SourceRecently Updated
General

Habitat-GS-Navigator

Navigate and interact with photo-realistic 3DGS environments via the Habitat-GS Bridge. Use when: user asks to explore a 3D scene, perform embodied navigatio...

Registry SourceRecently Updated
General

Memory Palace

持久化记忆管理。Use when: 用户告诉你个人信息/偏好/习惯、需要记住项目状态/技术决策、完成任务后有可复用经验、用户说"记住""别忘了""下次注意"、需要回忆之前的对话内容。支持语义搜索和时间推理。

Registry SourceRecently Updated
General

Podcast Transcript Mining Authority Positioning

Extract guest appearances, speaking topics, and soundbites from podcast transcripts to build authority portfolios and generate podcast pitch templates. Use w...

Registry SourceRecently Updated