本文へ移動
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(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

bmad-init

無料

Initialize or update BMad-Method (V6) in your project

日本語の概要は準備中です。原文の説明を表示しています。

UfoMiao/zcf6,0772026年8月31日 更新

bmad-init

無料

在项目中初始化或更新 BMad-Method (V6)

日本語の概要は準備中です。原文の説明を表示しています。

UfoMiao/zcf6,0772026年8月31日 更新

feat

無料

Add New Feature

日本語の概要は準備中です。原文の説明を表示しています。

UfoMiao/zcf6,0772026年8月31日 更新

feat

無料

用于新增功能开发的命令,支持完整的开发流程和工具集成

日本語の概要は準備中です。原文の説明を表示しています。

UfoMiao/zcf6,0772026年8月31日 更新

安全查找并清理已合并或过期的 Git 分支,支持 dry-run 模式与自定义基准/保护分支

日本語の概要は準備中です。原文の説明を表示しています。

UfoMiao/zcf6,0772026年8月31日 更新

Safely find and clean up merged or stale Git branches with dry-run mode and custom base/protected branches support

日本語の概要は準備中です。原文の説明を表示しています。

UfoMiao/zcf6,0772026年8月31日 更新

UfoMiao のスキルをすべて見る

このスキルの問題を報告する