How to save a set of changes for later: a quick guide to using git stash.

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: