← 返回
未分类 中文

git-version-control

Git-based version control for OpenClaw system configuration changes. Provides two core capabilities: (1) SAVE - Create a checkpoint before sensitive operatio...
Git-based version control for OpenClaw system configuration changes. Provides two core capabilities: (1) SAVE - Create a checkpoint before sensitive operatio...
welkeyever welkeyever 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 232
下载
💾 1
安装
1
版本
#latest

概述

Git Version Control | OpenClaw Configuration Protection

> Protect your OpenClaw environment with git-based checkpoints and rollback capability.

Overview

OpenClaw configuration directory (~/.openclaw/) is a git repository. This skill provides safe version control for system configuration changes.

Protected files include:

  • workspace/SOUL.md, AGENTS.md, USER.md, IDENTITY.md
  • workspace/skills/ - installed skills
  • workspace/memory/ - memory files
  • openclaw.json - main configuration
  • cron/jobs.json - cron jobs

Excluded from version control:

  • Session logs (.jsonl, .jsonl.lock)
  • SQLite databases (*.sqlite)
  • Temporary files
  • Credentials (sensitive)

Core Operations

1. SAVE - Create Checkpoint

Create a git commit before making sensitive changes. This provides a recovery point.

When to use:

  • Before modifying core configuration files
  • Before installing/uninstalling skills
  • Before making bulk memory changes
  • User explicitly requests a save point

Command Flow:

cd ~/.openclaw

# Check current status
git status

# Add all tracked files (respecting .gitignore)
git add -A

# Create commit with descriptive message
git commit -m "checkpoint: {description of pending change}"

Implementation:

When user says: "save before..." or "create checkpoint"

1. Generate descriptive commit message based on context
2. Run: git add -A
3. Run: git commit -m "checkpoint: {description}"
4. Report commit hash and file count to user

Example:

User: "Save before I install a new skill"
Action:
  git add -A
  git commit -m "checkpoint: before installing new skill"
Output: "✓ Checkpoint created: abc1234 (5 files changed)"

2. ROLLBACK - Restore Previous State

Revert to a previous commit when issues occur.

When to use:

  • User reports system issues after recent changes
  • User explicitly requests rollback
  • Configuration corruption detected
  • After a failed skill installation

Rollback Options:

OptionCommandEffect
-------------------------
Soft resetgit reset --soft HEAD~1Undo commit, keep changes staged
Mixed resetgit reset --mixed HEAD~1Undo commit, keep changes unstaged
Hard resetgit reset --hard HEAD~1Completely undo commit and changes

Recommended default: --hard for full rollback

Implementation:

When user says: "rollback" or "undo last change" or "restore previous"

1. Show recent commits for user to choose
   git log --oneline -10
   
2. Confirm which commit to restore to
   "Rollback to commit X? This will discard: {list changes}"
   
3. Execute rollback
   git reset --hard {commit-hash}
   
4. Report result
   "✓ Rolled back to commit abc1234"

Example:

User: "Rollback to before the skill installation"
Action:
  git log --oneline -5
  # Show: abc1234 checkpoint: before skill install
  #       def5678 previous config
  git reset --hard abc1234
Output: "✓ Rolled back to 'before skill install' (abc1234)"

Helper Operations

View History

# Show recent commits
git log --oneline -10

# Show what changed in last commit
git show --stat HEAD

# Compare current state to last commit
git diff HEAD

Check Status

# See uncommitted changes
git status

# See diff summary
git diff --stat

List Protected Files

Files tracked for version control (in git):

git ls-files

.gitignore Configuration

Ensure ~/.openclaw/.gitignore excludes volatile/sensitive files:

# Session logs (volatile)
*.jsonl
*.jsonl.lock
*.jsonl.reset.*

# Databases (volatile)
*.sqlite
*.sqlite-journal

# Credentials (sensitive)
credentials/
*.pem
*.key

# Temporary files
*.tmp
*.temp
.DS_Store

# Logs
logs/

# Delivery queue
delivery-queue/

Decision Tree

User requests sensitive operation
        ↓
    Is SAVE needed?
    ┌─────┴─────┐
   Yes          No
    ↓            ↓
 SAVE first   Execute directly
    ↓
Execute operation
    ↓
  Success?
  ┌─────┴─────┐
 Yes          No
  ↓            ↓
 Done      ROLLBACK?
           ┌─────┴─────┐
          Yes          No
           ↓            ↓
       Rollback     Debug manually

Integration with Other Skills

SkillIntegration
--------------------
self-improvementRecord rollback events as learnings
skill-creatorAuto-SAVE before creating new skills
healthcheckCheck git status during health checks

Safety Guidelines

✅ Best Practices

  1. Always SAVE before risky operations
    • Installing skills from external sources
    • Modifying AGENTS.md, SOUL.md
    • Bulk memory updates
  1. Use descriptive commit messages

```

checkpoint: before installing news skill

checkpoint: before modifying SOUL.md persona

checkpoint: before cron job changes

```

  1. Verify before ROLLBACK
    • Show what will be lost
    • Confirm with user for hard reset

❌ Avoid

  1. Don't rollback without confirmation
    • Hard reset destroys uncommitted changes
    • Always warn user about data loss
  1. Don't commit sensitive data
    • Check .gitignore excludes credentials
    • Never add credentials/ to git
  1. Don't use for session data
    • Session logs are excluded intentionally
    • Focus on configuration, not runtime data

Quick Reference

ActionCommandAlias
------------------------
SAVE checkpointgit add -A && git commit -m "checkpoint: {desc}"save
ROLLBACKgit reset --hard HEAD~1rollback
View historygit log --oneline -10history
Check statusgit statusstatus
Compare diffgit diff HEADdiff

Example Session

User: Install a new skill from ClawHub

Agent (internal):
  1. SAVE checkpoint first
     $ git add -A
     $ git commit -m "checkpoint: before installing {skill-name}"
     ✓ Checkpoint: abc1234

  2. Install skill
     $ clawhub install {skill-name}
     
  3. Verify success
     ✓ Skill installed successfully
     
User: That skill broke something, rollback!

Agent:
  1. Show options
     $ git log --oneline -3
     abc1234 checkpoint: before installing {skill-name}
     def5678 previous state
     
  2. Confirm rollback
     "Rollback to abc1234? This will remove the newly installed skill."
     
  3. Execute
     $ git reset --hard abc1234
     ✓ Rolled back successfully

_Last updated: 2026-03-05_

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-12 06:09 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

YouTube

byungkyu
使用托管OAuth集成YouTube Data API,支持搜索视频、管理播放列表、获取频道数据及评论互动,适用于用户需要时使用此技能。
★ 142 📥 42,113
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 686 📥 331,065
ai-agent

PAFH-Memory

welkeyever
**PAHF(基于人类反馈的个性化智能体)— 持续个性化框架** 触发条件为执行 PAHF 三步循环时: 1. **行动前澄清**(Pre-action Clarif...) --- *原文似乎被截断,请提供完整内容以便完整翻译。*
★ 1 📥 641