跳到正文
cccskills
免费在 GitHub 公开

git-rollback

Interactively rollback Git branch to historical version; lists branches, versions, then executes reset/revert after confirmation

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md4.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Claude Command: Git Rollback

Purpose: Safely and visually rollback a specified branch to an older version. Defaults to read-only preview (--dry-run); actual execution requires --yes or interactive confirmation.


Usage

# Pure interactive: list branches → select branch → list recent 20 versions → select target → choose reset or revert → confirm
/git-rollback

# Specify branch, other interactive
/git-rollback --branch feature/calculator

# Specify branch and target commit, execute with hard-reset in one go (dangerous)
/git-rollback --branch main --target 1a2b3c4d --mode reset --yes

# Generate revert commit only (non-destructive rollback), preview
/git-rollback --branch release/v2.1 --target v2.0.5 --mode revert --dry-run

Options

OptionDescription
--branch <branch>Branch to rollback; interactively selected if omitted.
--target <rev>Target version (commit hash, tag, or reflog reference); interactively selects recent --depth entries if omitted.
--mode reset|revertreset: Hard rollback history; revert: Generate reverse commits keeping history intact. Prompts by default.
--depth <n>List recent n versions in interactive mode (default 20).
--dry-runEnabled by default, only preview commands to be executed.
--yesSkip all confirmations and execute directly, suitable for CI/CD scripts.

Interactive Flow

  1. Sync remote → git fetch --all --prune
  2. List branches → git branch -a (local + remote, filter protected branches)
  3. Select branch → User input or parameter
  4. List versions → git log --oneline -n <depth> + git tag --merged + git reflog -n <depth>
  5. Select target → User inputs commit hash / tag
  6. Select mode → reset or revert
  7. Final confirmation (unless --yes)
  8. Execute rollback
    • reset: git switch <branch> && git reset --hard <target>
    • revert: git switch <branch> && git revert --no-edit <target>..HEAD
  9. Push suggestion → Prompt whether to git push --force-with-lease (reset) or regular git push (revert)

Safety Guards

  • Backup: Automatically records current HEAD in reflog before execution, recoverable with git switch -c backup/<timestamp>.
  • Protected branches: If protected branches like main / master / production are detected with reset mode enabled, requires additional confirmation.
  • --dry-run enabled by default: Prevents accidental operations.
  • --force prohibited: No --force provided; if force push needed, manually enter git push --force-with-lease.

Use Case Examples

ScenarioCommand Example
Hotfix patch deployed with bug, need to rollback to tag v1.2.0/git-rollback --branch release/v1 --target v1.2.0 --mode reset
Ops colleague pushed debug logs by mistake, need to generate reverse commit/git-rollback --branch main --target 3f2e7c9 --mode revert
Research historical bugs, guide newcomers through branch history/git-rollback (full interactive, dry-run)

Notes

  1. reset vs revert
    • reset changes history, requires force push and may affect other collaborators, use with caution.
    • revert is safer, generates new commits preserving history, but adds one more record.
  2. Embedded repositories often have large binary files; ensure LFS/submodule state consistency before rollback.
  3. If repository has CI forced validation, rollback may trigger pipelines automatically; confirm control policies to avoid accidental deployment of old versions.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

bmad-init

免费

Install or update BMad-Method (V6) in a project after checking existing installations. The skill also fixes a known output-folder issue, updates Git ignore rules, and provides next steps for using the installed workflows.

中文简介正在准备中。当前显示英语简介。

  • Set up BMad-Method (V6) for Claude Code
  • Run a quick update on an existing V6 installation
  • Check for an older V4 installation before setup
UfoMiao/zcf60812026年8月31日 更新

bmad-init

免费

Set up or update BMad-Method V6 in a project, detect older installations, fix a known output folder issue, and adjust Git ignore rules, with guidance on what to do next.

中文简介正在准备中。当前显示英语简介。

  • Installing BMad-Method V6 in a project
  • Updating an existing V6 installation
  • Checking for an older V4 installation
UfoMiao/zcf60812026年8月31日 更新

feat

免费

Turn feature requests into documented plans, revise them through discussion, and carry out implementation with progress tracking. Frontend work includes checking for a UI design and arranging design work when needed.

中文简介正在准备中。当前显示英语简介。

  • Turning a feature idea into a development plan
  • Revising a plan after feedback
  • Implementing tasks from an agreed plan
UfoMiao/zcf60812026年8月31日 更新

feat

免费

Guide new feature work from requirements and planning through revisions and implementation. Create Markdown plans with acceptance criteria, track progress, and ensure frontend tasks have a UI design before development begins.

中文简介正在准备中。当前显示英语简介。

  • Turn a feature idea into an implementation plan
  • Revise a plan based on feedback
  • Start implementation from an agreed plan
UfoMiao/zcf60812026年8月31日 更新

Find Git branches that have been merged or inactive for a chosen period. Preview cleanup candidates, exclude protected branches, and delete local or remote branches using a selected base branch and confirmation options.

中文简介正在准备中。当前显示英语简介。

  • Find merged branches to clean up
  • Review branches with no recent commits
  • Clean up branches merged into a release
UfoMiao/zcf60812026年8月31日 更新

Find merged or inactive Git branches, preview cleanup candidates, and delete selected branches after confirmation. Choose a comparison branch, protect important branches with configurable rules, and optionally include remote branches.

中文简介正在准备中。当前显示英语简介。

  • Previewing branch cleanup candidates
  • Removing branches already merged into a release branch
  • Finding branches with no recent commits
UfoMiao/zcf60812026年8月31日 更新

查看 UfoMiao 的全部技能

报告此技能的问题