DEV Community

Danyson
Danyson

Posted on

How to temporarily save your uncommitted changes using Git Stash?

Use git stash to temporarily save your uncommitted changes.

Steps:

  1. Make some changes to your files.
  2. Run git status to see that you have uncommitted changes.
  3. Run git stash to save your uncommitted changes.
  4. Make some more changes to your files.
  5. Run git status to see that you have uncommitted changes again.
  6. Run git stash list to see your stashed changes.
  7. Run git stash apply to apply your first stashed changes and restore your working directory to the state it was in before you ran git stash.
  8. Run git stash pop to apply your first stashed changes and delete them from the stash.

This trick can be useful if you need to temporarily switch to a different branch or work on another task without losing your uncommitted changes.

My Website: danyson.netlify.app
My LinkedIn: linkedin/danyson

Top comments (0)