Skip to content
Development
Skill

/git-rollback

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

From plugin
zcf
6.1k12 skills1 agent

Claude Code

$ npx -y skills add UfoMiao/zcf --skill git-rollback --agent claude-code

SKILL.md

git-rollback.SKILL.md
name: git-rollback
description: Interactively rollback Git branch to historical version; lists branches, versions, then executes reset/revert after confirmation
disable-model-invocation: true
allowed-tools: Read(**), Exec(git fetch, git branch, git tag, git log, git reflog, git checkout, git reset, git revert, git switch), Write()

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

| Option | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------ | | `--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\|revert` | `reset`: 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-run` | **Enabled by default**, only preview commands to be executed. | | `--yes` | Skip 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

| Scenario | Command 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.

---

Read more
@ufomiao
Ships withzcf

Zero-Config Code Flow for Claude code & Codex

6.1k12 skills1 agent
Get the whole plugin

Stars on GitHub

Momentum

stars in total
6.1k
Star history of UfoMiao/zcf on GitHub, a chart by star-history.com

Other skills on zcf.

zcf-add-sponsor

zcf-add-sponsor

Quickly add a new corporate sponsor to ZCF — sponsor list by default, with optional API preset and documentation ad placements

@ufomiao@ufomiaoInstall Skill
zcf-pr

zcf-pr

Create a pull request for the current branch with a description based on the project PR template

@ufomiao@ufomiaoInstall Skill
zcf-release

zcf-release

Prepare a ZCF release with changesets, a bilingual changelog, a release branch and a pull request

@ufomiao@ufomiaoInstall Skill
zcf-update-docs

zcf-update-docs

Bring docs/ (en, zh-CN, ja-JP) and AGENTS.md in line with code changes since the last release tag

@ufomiao@ufomiaoInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react5d252k
@facebook@facebookInstall Skill

Questions about git-rollback.

Which coding agents can use git-rollback?
git-rollback installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.