Repaso
EspaƱol
Maven, Git & SDLCIntermediateVCS-14

What does git stash do?

Options

  1. Deletes uncommitted changes forever, with no way back
  2. Saves uncommitted changes on a stack; stash pop restores (Correct option)
  3. Pushes the uncommitted changes to the remote branch
  4. Creates a tag on the current commit of the branch

Answer

Temporarily saves your uncommitted changes on a stack and cleans the working directory, so you can switch tasks; git stash pop brings them back

Why

You are halfway through a change and need to switch branch to fix something urgent. You do not want to commit unfinished work.

git stash stores your changes in a temporary shelf and gives you a clean directory. Later git stash pop reapplies them (and removes them from the shelf); git stash list shows the stack.

Remember

stash = shelf for unfinished work.

Key terms

Practice this question in Repaso