A quick guide to git stash: how to save & restore a set of local changes for later.

If you're working on your user branch developing a feature and suddenly need to switch to a different problem without comitting incomplete code, you can use stash your changes.

How to stash changes in git:

Stashing your changes will preserve them for later.

  
  git stash
  

Save all local changes.

  
  git stash --patch
  

Save a specific file via interactive patch mode. Further reading .

How to restore stashed changes:

After restoring stashed changes, you can choose to either preserve or discard the changes from the stack.

  
  git apply
  

Preserve changes in the stack.

  
  git stash pop
  

Discard changes from the stack.

More reading related to git: