Article Image
read

Git stash is awesome. You work on a feature/bug and suddenly having a context switch (a new urgent hotfix / a team member asking for help in another brunch). Now, you want to save your work aside without committing it. Git stash FTW!

A basic stash will be:

Saving a stash

git stash

Save a stash with a save name:

git stash save "my temp work"

Fetching back last stash, popping it from stash stack

git stash pop

Fetching back last stash, leaving it on stash stack

git stash apply

As you can see, stash is a stack of changes. What if you want to fetch an old stash? Retrieving list of stashes

git stash list

This will produce a list of stashes:

stash@{0}: On feature/AD-292: controller api mock
stash@{1}: On feature/AD-350: vast fake json
stash@{2}: On feature/AD-315: vast another fake json
stash@{3}: On feature/AD-350: vast validator
stash@{4}: On feature/AD-292: controller 11.1.15
...

In order to fetch a specific stash:

git stash pop stash@{n}

Or

git stash apply stash@{n} 

And a last tip: you can see stash's changes by:

git stash show -p stash@{n}

Good luck!

Blog Logo

Yaniv Efraim


Published

Image

Advanced Front End topics

Back to Overview