git-stash-pop-pulls-unrelated-stash

git-stash-pop-pulls-unrelated-stash is a skill for Claude Code from wan-huiyan/agent-traffic-control. It costs 221 tokens per session (1,808 once invoked), scanned A, original, MIT.

A Git troubleshooting guide about the stash stack, which is a shared list of saved working changes. It explains how `git stash pop` can restore an old stash from another branch after a new `git stash` saved nothing.

In plain words
What is it for?
Use it when `git stash` says “No local changes to save” but `git stash pop` brings back unfamiliar files, conflicts, or work from another branch.
Why use it?
It helps prevent unrelated changes and merge conflicts from appearing in a clean working tree. It also explains why a successful `git stash` command does not guarantee that `stash pop` is safe.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: mentions Claude Code.

Part of the agent-traffic-control plugin — 105 skills shipped together

Good fit Use it when git stash says “No local changes to save” but git stash pop brings back unfamiliar files, conflicts, or work from another branch.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wan-huiyan/agent-traffic-control/git-stash-pop-pulls-unrelated-stash
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add wan-huiyan/agent-traffic-control --skill git-stash-pop-pulls-unrelated-stash
Clone the repo
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control

Made for: Claude Code.

Or install agent-traffic-control, the plugin that ships this one along with the rest of its 105 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for git-stash-pop-pulls-unrelated-stash

README.md
[![agentmods](https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/git-stash-pop-pulls-unrelated-stash/github.svg)](https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/git-stash-pop-pulls-unrelated-stash)
Your own site
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/git-stash-pop-pulls-unrelated-stash"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/git-stash-pop-pulls-unrelated-stash/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for git-stash-pop-pulls-unrelated-stash

Your own site · 80×15
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/git-stash-pop-pulls-unrelated-stash"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/git-stash-pop-pulls-unrelated-stash.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 221 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,808 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00221 $0.01808
Opus 5 $0.00111 $0.00904
Sonnet 5 $0.00044 $0.00362
Haiku 4.5 $0.00022 $0.00181

Measured 12d ago against content hash ac4292caaa1c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

git-stash-pop-pulls-unrelated-stash scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/agent-traffic-control/skills/git-stash-pop-pulls-unrelated-stash/SKILL.md · 178 lines

How it starts

The opening of the file, as written. The whole thing — 178 lines — stays where its author put it; the contents beside it link to each section on GitHub.

git stash pop pulls an unrelated stash when preceding git stash was a no-op

Problem

You defensively wrap a risky operation with git stash / ... / git stash pop to preserve in-progress work. The working tree is clean, so git stash prints "No local changes to save" and exits 0. Later, git stash pop pulls in modifications from a different branch's stash entry — sometimes months old, sometimes from another worktree, often producing merge conflicts in files you never touched in this session.

Context / Trigger Conditions

You'll see one or more of:

  • git stash immediately echoed "No local changes to save"
  • git stash pop runs without error and announces something like On branch <X>: WIP on <other-branch>: <sha> <commit-msg-from-elsewhere>
  • git status afterward shows:
    • Modified or unmerged files you didn't touch
    • both modified: <path> for paths from unrelated features
    • Filenames matching files on entirely different branches
  • git stash list shows entries like stash@{0}: WIP on feature/sca-polish: ... that reference branches you're not on

Root Cause

The stash stack is a global, branch-agnostic, LIFO data structure, shared across every worktree of the repo. git stash pop always pops stash@{0} — it doesn't care which branch the stash was created on. When git stash is a no-op (clean tree), nothing is pushed onto the stack, so a subsequent git stash pop reaches whatever was on top before this session — potentially unrelated work from another branch, sometimes from months ago.

Solution

Prevent

  1. Don't pair git stash / git stash pop reflexively. Check the output of git stash first:
    git stash push -m "session-N defensive snapshot" 2>&1 | tee /tmp/stash-msg
    grep -q "Saved working directory" /tmp/stash-msg && DID_STASH=1 || DID_STASH=0
    # ... do risky thing ...
    [ "$DID_STASH" = "1" ] && git stash pop
    
  2. Always use -m with git stash push so your stash entries are identifiable in git stash list.
  3. Audit before popping when you're unsure:
    git stash list | head -5    # show top of stack
    git stash show -p stash@{0} # full diff
    
  4. Use a worktree-scoped stash alternative. Instead of git stash, commit to a throwaway branch:
    git checkout -b /tmp/snapshot-$$
    git add -A && git commit -m "snapshot"
    git checkout -
    # later: git cherry-pick /tmp/snapshot-$$ ; git branch -D /tmp/snapshot-$$
    

Read the full file on GitHub · 178 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 178 lines · 221 tokens per session scan A ac4292caaa1c

Subscribe to this mod's changes

git-stash-pop-pulls-unrelated-stash is a skill published in the GitHub repository wan-huiyan/agent-traffic-control (3 stars, last pushed today), licensed MIT. It adds 221 tokens to every session and 1,808 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

cloudflare-workers-ci-cd

Complete CI/CD guide for Cloudflare Workers using GitHub Actions and GitLab CI. Use for automated testing, deployment pipelines, preview environments, secrets management, or encountering deployment failures, workflow errors, environment configuration issues.

secondsky/claude-skills · 50 tokens

claude-code-bash-patterns

Claude Code Bash tool patterns with hooks, automation, git workflows. Use for PreToolUse hooks, command chaining, CLI orchestration, custom commands, or encountering bash permissions, command failures, security guards, hook configurations.

secondsky/claude-skills · 52 tokens

bump-sdk-version

Bump the FutureSearch SDK version across all files. Use when releasing a new SDK version, updating version numbers, or the user says bump version, release, version bump.

futuresearch/futuresearch-python · 40 tokens

pr-check

PR review compliance: fetch review comments from an open PR, categorize as resolved/unresolved/dismissed, critically evaluate fixable items, implement approved fixes, and reply inline. Pass --unattended to halt on human-judgment items (emitted as Pending-Human) instead of prompting via AskUserQuestion.

rube-de/cc-skills · 67 tokens

babysit

PR babysitter: monitors CI status, auto-rebases when behind, auto-fixes CI where possible, delegates review comment handling to dlc:pr-check, and re-requests review after fixes. Designed for /loop usage with Remote Control.

rube-de/cc-skills · 53 tokens

git-ops

Git hygiene: clean up merged branches, prune stale remotes, and verify repository state.

rube-de/cc-skills · 22 tokens