ada-git-destructive-operations

Guides safe git branch resets and local commit deletion with recovery checks.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/wubing7755/Ada --skill ada-git-destructive-operations-wubing7755
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ada-git-destructive-operations
Source: https://github.com/wubing7755/Ada/tree/main/skills/software-development/ada-git-destructive-operations
Command: npx skills add https://github.com/wubing7755/Ada --skill ada-git-destructive-operations-wubing7755

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Deleting local commits or resetting branches with git is irreversible when commits were never pushed, and requests like "delete local commits" are ambiguous between hard resets, merge aborts, and rebases. This Skill prevents irreversible data loss by enforcing state detection, remote-backup verification, and explicit intent confirmation before any destructive git command runs. ## Core Features & Use Cases - Pre-destruction state detection: Runs git status, git branch -vv, and rev-list --left-right --count to determine divergence, in-progress merges, staged changes, and whether local commits exist on a remote backup. - Intent disambiguation: Presents concrete options (hard reset to origin, abort merge and keep commits, or rebase onto remote) with recovery paths stated, never a bare yes/no. - Rebase-merge branch cleanup: Handles branches that appear unmerged after rebase-and-merge or squash-merge PRs by verifying content landed on main before force-deleting SHA-rewritten branches. - Use Case: A user says "放弃这些提交" on a diverged branch with an in-progress merge. The Skill detects the merge state, checks whether the 3 local commits were pushed, warns that staged changes will be destroyed, and only executes git reset --hard origin/main after the user picks that option explicitly. ## Quick Start Ask the agent to delete your local commits or reset your branch to origin, and it will verify the state and confirm your intent before running anything destructive.

Frequently Asked Questions about ada-git-destructive-operations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely delete local git commits?

First run git status and git branch -vv to detect divergence and staged changes, then use git rev-list --left-right --count to check whether the commits exist on a remote. If pushed, git reset --hard origin/<branch> is recoverable; if never pushed, deletion is irreversible and needs explicit confirmation.

How to reset a local branch to origin main?

Fetch the remote with git fetch origin, verify the commit counts with rev-list, then run git reset --hard origin/main after confirming intent. This also clears any in-progress merge state, but it destroys staged changes and unmerged paths, so warn about those first.

Why does git branch --merged not show my branch after a rebase merge?

Rebase-and-merge and squash merges rewrite commits onto main with new SHAs, so git's SHA comparison no longer recognizes the local branch as merged. Confirm the content landed on main by grepping the log for the feature topic, then force-delete with git branch -D.

What is the difference between aborting a merge and discarding commits?

Aborting a merge with git merge --abort clears the in-progress merge state while keeping your local commits intact. Discarding commits via git reset --hard removes both the merge state and the commits themselves, which is only recoverable if those commits were already pushed to a remote.

Can deleted local commits be recovered after git reset --hard?

Recovery depends on whether the commits were pushed before the reset. If they exist on a remote branch, git reset --hard origin/<branch> or git checkout -B restores them; local-only commits that were never pushed have no reliable recovery path through the remote.