Git Recovering Recover from git stash

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

To get your most recent stash after running git stash, use

git stash apply

To see a list of your stashes, use

git stash list

You will get a list that looks something like this

stash@{0}: WIP on master: 67a4e01 Merge tests into develop
stash@{1}: WIP on master: 70f0d95 Add user role to localStorage on user login

Choose a different git stash to restore with the number that shows up for the stash you want

git stash apply stash@{2}

You can also choose 'git stash pop', it works same as 'git stash apply' like..

 git stash pop 

or

 git stash pop stash@{2}

Difference in git stash apply and git stash pop...

git stash pop:- stash data will be remove from stack of stash list.

Ex:-

git stash list

You will get a list that looks something like this

stash@{0}: WIP on master: 67a4e01 Merge tests into develop
stash@{1}: WIP on master: 70f0d95 Add user role to localStorage on user login

Now pop stash data using command

git stash pop

Again Check for stash list

git stash list

You will get a list that looks something like this

 stash@{0}: WIP on master: 70f0d95 Add user role to localStorage on user login

You can see one stash data is removed (popped) from stash list and stash@{1} became stash@{0}.



Got any Git Question?