# What Is git stash?

> What is git stash? An explainer on temporarily shelving uncommitted changes to switch context, how to restore them, and why stashes stay local and out of CI.

Source: https://latchkey.dev/learn/ci-explained/what-is-git-stash  
Updated: 2026-06-26

git stash temporarily sets aside your uncommitted changes so you can switch context with a clean working directory, then restore them later.

git stash is the quick way to put your current work on a shelf. When something urgent comes up and you are not ready to commit, stashing tucks your uncommitted changes away, gives you a clean slate, and lets you bring the work back when you return.

## What stashing does

Stashing records your uncommitted modifications, both staged and unstaged, and reverts your working directory to the last commit. The changes are saved on a stash stack you can reapply later. It is a lightweight pause button, not a commit, and stays entirely on your machine.

## Stashing and restoring

You stash, do the urgent work, then pop the stash to bring your changes back.

```Shelving and restoring work
git stash push -m "WIP form layout"
# handle the interruption
git stash pop
```

## When stashing helps

Stashing is handy when you need to switch branches to fix something urgent, pull in updates onto a clean tree, or temporarily clear changes to test a clean build. You can keep multiple stashes and apply them selectively, though deep stash stacks get confusing.

## Stash and CI/CD

Stashes are purely local and are never pushed, so CI never sees them. That is by design: a pipeline builds committed history, not someone's shelved work in progress. If you want CI to test something, you must commit and push it; stashed changes simply do not exist on the remote.

## Using stash wisely

- Stash to switch context without committing half-done work.
- Add a message so you remember what each stash holds.
- Avoid letting stashes pile up and grow stale.
- Remember stashes are local; commit to get changes into CI.

## Applying this to your pipeline

- Measure before changing. Most CI optimisation targets the wrong step because the slow one is assumed rather than timed.
- Cache what is expensive to produce and cheap to validate, and key the cache to the exact tool version.
- Fail fast: run the cheapest checks that can reject a change first, so an expensive job never starts on code that cannot pass.
- Prefer determinism over speed when they conflict. A fast pipeline nobody trusts gets re-run, which is slower than a slow one that is believed.

## FAQ

### What is What is git stash??

git stash is the quick way to put your current work on a shelf. When something urgent comes up and you are not ready to commit, stashing tucks your uncommitted changes away, gives you a clean slate, and lets you bring the work back when you return.

### What stashing does?

Stashing records your uncommitted modifications, both staged and unstaged, and reverts your working directory to the last commit. The changes are saved on a stash stack you can reapply later. It is a lightweight pause button, not a commit, and stays entirely on your machine.

### Stashing and restoring?

You stash, do the urgent work, then pop the stash to bring your changes back.

### When stashing helps?

Stashing is handy when you need to switch branches to fix something urgent, pull in updates onto a clean tree, or temporarily clear changes to test a clean build. You can keep multiple stashes and apply them selectively, though deep stash stacks get confusing.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
