KKAIROSافتح التطبيق
Practical guideTested1 min read

Git stash: put unfinished work aside and bring it back

Published:

Advertisement

When to use it

You changed a file but need to switch tasks and the work is not ready to commit.

git stash
git stash pop

git stash list shows saved stashes.

Steps in order

  1. In the middle of unfinished work, run git stash. Files go back to the last commit.
  2. Do the other task.
  3. See what is saved with git stash list.
  4. Get your work back with git stash pop.

Untracked files

Pop, apply or drop

Is stash safe for long-term storage?

It is meant for short breaks. Use a branch and a commit for work you want to keep for days.

Which branch does pop restore onto?

The one you are on when you run it, so you can stash on one branch and pop on another.

Source: https://git-scm.com/docs/git-stash

Full kit: Git Survival Kit