Advanced git operations beyond add/commit/push. Use when rebasing, bisecting bugs, using worktrees for parallel development, recovering with reflog, managing subtrees/submodules, resolving merge conflicts, cherry-picking across branches, or working with monorepos.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install git-workflows或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install git-workflows⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/git-workflows/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: git-workflows description: Advanced git operations beyond add/commit/push. Use when rebasing, bisecting bugs, using worktrees for parallel development, recovering with reflog, managing subtrees/submodules, resolving merge conflicts, cherry-picking across branches, or working with monorepos. metadata: {"clawdbot":{"emoji":"🌿","requires":{"bins":["git"]},"os":["linux","darwin","win32"]}} ---
Advanced git operations for real-world development. Covers interactive rebase, bisect, worktree, reflog recovery, subtrees, submodules, sparse checkout, conflict resolution, and monorepo patterns.
# Rebase last 5 commits interactively
git rebase -i HEAD~5
# Rebase onto main (all commits since diverging)
git rebase -i main
The editor opens with a pick list:
pick a1b2c3d Add user model
pick e4f5g6h Fix typo in user model
pick i7j8k9l Add user controller
pick m0n1o2p Add user routes
pick q3r4s5t Fix import in controller
Commands available:
pick = use commit as-is
reword = use commit but edit the message
edit = stop after this commit to amend it
squash = merge into previous commit (keep both messages)
fixup = merge into previous commit (discard this message)
drop = remove the commit entirely
# Squash fix commits into their parent
# Change "pick" to "fixup" for the fix commits:
pick a1b2c3d Add user model
fixup e4f5g6h Fix typo in user model
pick i7j8k9l Add user controller
fixup q3r4s5t Fix import in controller
pick m0n1o2p Add user routes
# Reorder commits (just move lines)
pick i7j8k9l Add user controller
pick m0n1o2p Add user routes
pick a1b2c3d Add user model
# Split a commit into two
# Mark as "edit", then when it stops:
git reset HEAD~
git add src/model.ts
git commit -m "Add user model"
git add src/controller.ts
git commit -m "Add user controller"
git rebase --continue
# When committing a fix, reference the commit to squash into
git commit --fixup=a1b2c3d -m "Fix typo"
# or
git commit --squash=a1b2c3d -m "Additional changes"
# Later, rebase with autosquash
git rebase -i --autosquash main
# fixup/squash commits are automatically placed after their targets
git rebase --abort # Cancel and restore original state
git rebase --continue # Continue after resolving conflicts or editing
git rebase --skip # Skip the current commit and continue
# Start bisect
git bisect start
# Mark current commit as bad (has the bug)
git bisect bad
# Mark a known-good commit (before the bug existed)
git bisect good v1.2.0
# or: git bisect good abc123
# Git checks out a middle commit. Test it, then:
git bisect good # if this commit doesn't have the bug
git bisect bad # if this commit has the bug
# Repeat until git identifies the exact commit
# "abc123 is the first bad commit"
# Done — return to original branch
git bisect reset
# Fully automatic: git runs the script on each commit
# Script must exit 0 for good, 1 for bad
git bisect start HEAD v1.2.0
git bisect run ./test-for-bug.sh
# Example test script
cat > /tmp/test-for-bug.sh << 'EOF'
#!/bin/bash
# Return 0 if bug is NOT present, 1 if it IS
npm test -- --grep "login should redirect" 2>/dev/null
EOF
chmod +x /tmp/test-for-bug.sh
git bisect run /tmp/test-for-bug.sh
# If a commit doesn't compile, skip it
git bisect skip
# Skip a range of known-broken commits
git bisect skip v1.3.0..v1.3.5
# Add a worktree for a different branch
git worktree add ../myproject-hotfix hotfix/urgent-fix
# Creates a new directory with that branch checked out
# Add a worktree with a new branch
git worktree add ../myproject-feature -b feature/new-thing
# List worktrees
git worktree list
# Remove a worktree when done
git worktree remove ../myproject-hotfix
# Prune stale worktree references
git worktree prune
# Review a PR while keeping your current work untouched
git worktree add ../review-pr-123 origin/pr-123
# Run tests on main while developing on feature branch
git worktree add ../main-tests main
cd ../main-tests && npm test
# Compare behavior between branches side by side
git worktree add ../compare-old release/v1.0
git worktree add ../compare-new release/v2.0
# Show reflog (all HEAD movements)
git reflog
# Output:
# abc123 HEAD@{0}: commit: Add feature
# def456 HEAD@{1}: rebase: moving to main
# ghi789 HEAD@{2}: checkout: moving from feature to main
# Show reflog for a specific branch
git reflog show feature/my-branch
# Show with timestamps
git reflog --date=relative
# Undo a bad rebase (find the commit before rebase in reflog)
git reflog
# Find: "ghi789 HEAD@{5}: checkout: moving from feature to main" (pre-rebase)
git reset --hard ghi789
# Recover a deleted branch
git reflog
# Find the last commit on that branch
git branch recovered-branch abc123
# Recover after reset --hard
git reflog
git reset --hard HEAD@{2} # Go back 2 reflog entries
# Recover a dropped stash
git fsck --unreachable | grep commit
# or
git stash list # if it's still there
git log --walk-reflogs --all -- stash # find dropped stash commits
# Pick a single commit
git cherry-pick abc123
# Pick multiple commits
git cherry-pick abc123 def456 ghi789
# Pick a range (exclusive start, inclusive end)
git cherry-pick abc123..ghi789
# Pick without committing (stage changes only)
git cherry-pick --no-commit abc123
# Cherry-pick from another remote/fork
git remote add upstream https://github.com/other/repo.git
git fetch upstream
git cherry-pick upstream/main~3 # 3rd commit from upstream's main
# If conflicts arise:
# 1. Resolve conflicts in the files
# 2. Stage resolved files
git add resolved-file.ts
# 3. Continue
git cherry-pick --continue
# Or abort
git cherry-pick --abort
# Add a subtree
git subtree add --prefix=lib/shared https://github.com/org/shared-lib.git main --squash
# Pull updates from upstream
git subtree pull --prefix=lib/shared https://github.com/org/shared-lib.git main --squash
# Push local changes back to upstream
git subtree push --prefix=lib/shared https://github.com/org/shared-lib.git main
# Split subtree into its own branch (for extraction)
git subtree split --prefix=lib/shared -b shared-lib-standalone
# Add a submodule
git submodule add https://github.com/org/shared-lib.git lib/shared
# Clone a repo with submodules
git clone --recurse-submodules https://github.com/org/main-repo.git
# Initialize submodules after clone (if forgot --recurse)
git submodule update --init --recursive
# Update submodules to latest
git submodule update --remote
# Remove a submodule
git rm lib/shared
rm -rf .git/modules/lib/shared
# Remove entry from .gitmodules if it persists
...
安装 Git Workflows 后,可以对 AI 说这些话来触发它
Help me get started with Git Workflows
Explains what Git Workflows does, walks through the setup, and runs a quick demo based on your current project
Use Git Workflows to advanced git operations beyond add/commit/push
Invokes Git Workflows with the right parameters and returns the result directly in the conversation
What can I do with Git Workflows in my developer & devops workflow?
Lists the top use cases for Git Workflows, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/git-workflows/ 目录(个人级,所有项目可用),或 .claude/skills/git-workflows/(项目级)。重启 AI 客户端后,用 /git-workflows 主动调用,或让 AI 根据上下文自动发现并使用。
Git Workflows 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Git Workflows 可免费安装使用。请查阅仓库了解许可证信息。
Advanced git operations beyond add/commit/push. Use when rebasing, bisecting bugs, using worktrees for parallel development, recovering with reflog, managing subtrees/submodules, resolving merge conflicts, cherry-picking across branches, or working with monorepos.
Git Workflows 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Git Workflows
Identifies repetitive steps in your workflow and sets up Git Workflows to handle them automatically