Git stash: how to save changes without making a commit

Published on 2026-10-26 by frfrand

Save temporary work in Git without losing files or mixing branches

Git stash: how to save changes without making a commit

You're fixing a form, an urgent bug comes in, and you don't want to make an incomplete commit. git stash lets you save local changes while you work on something else. It's not a repository backup: it's a local temporary work stack.

The idea is to use it to solve a real problem, not to memorize commands because they look good in a screenshot. Let's go with the essentials, a work example, and the mistakes it's best to avoid.

What Git stash does and when it's useful

By default, Git saves tracked changes from the index and working directory to the stash. New untracked files are left out, unless you use -u. Ignored files require different treatment; avoid putting credentials in the stash thinking it's a safe place.

If you're learning, try it first in a test repository or environment. If you manage production, document the state before running anything that alters files, history, or data. That way you understand what changed and can recover if you make a mistake.

Example to copy and understand

git status
git stash push -u -m 'formulario a medias'
git stash list
git switch main
# después de resolver el problema
git switch mi-rama
git stash apply stash@{0}
git status

Don't copy the final command without checking the previous state. Branch names, host, user, or paths are examples; replace them with your project's. Some commands modify files or make requests that can write data.

How I would use it step by step

  1. Step 1. First check what modifications appear in git status.
  2. Step 2. Save with a descriptive message. -u includes new files, but not ignored ones.
  3. Step 3. Switch branches and attend to the incident; verify that the directory is clean before switching.
  4. Step 4. Return to your branch, use apply to recover without deleting the stash and review conflicts.
  5. Step 5. After verifying and creating the commit, you can delete that entry with git stash drop.

Stop after each step and check the result. If something fails, note the exact message before changing strategy. Jumping between five random solutions usually makes it harder to find the real cause.

A case that could happen to you working with clients

You have a Django API and the reservation frontend halfway done. A payment webhook fails. You save the frontend change, fix the webhook on another branch, publish the commit and recover the form without manually copying files.

The goal is not for it to "work once", but for you to be able to explain how you repeat it without compromising another application. If there is customer data or credentials, work with separate tests and minimal accesses.

The error I see most

git stash pop applies and, if it ends well, deletes the entry; apply keeps it. If the changes matter to you, start with apply. The stash lives in the local clone: it is not a backup synchronized to GitHub.

A simple rule: if you can't explain what the command will do to your code or server, check its official help first. This way you avoid confusing a quick fix with a new problem.

Where does ArduMaker come in?

In a project deployed with Git from ArduMaker, record the exact commit that goes to production. The stash is only useful for organizing work on your machine; the server must deploy a verifiable revision.

For example, you can deploy from a Git repository to a VPS, associate an HTTPS domain, and manage services and databases from the same environment. The panel reduces repetitive infrastructure tasks, but it does not replace Git, testing, or reviewing project permissions.

Quick questions before applying it

Does this change production? It depends on where you execute the action. Test locally first, identify the affected commit or service, and prepare a recovery plan.

How do I check that it went well? Don't settle for the absence of error messages: check the status, run a functional test, and verify the corresponding logs or history.

Is it worth automating it? If it is repeatable and has verifiable results, yes. But automation should fail clearly and not hide errors or credentials.

To expand

Summary: the useful tool is not the one with the most options, but the one that allows you to understand what changed, verify it, and keep working without surprises.

  • Git
  • Tutorial
  • ArduMaker

Keep reading

All articles · VPS plans