Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the stash back after pulling

Yesterday I made some changes on the master branch but didn't commit them, today I tried to pull the master but it said I have to commit or stash my changes Please, commit your changes or stash them before you can merge. I stashed them git stash and then pulled from master git pull now I have done some changes in my code but figured out that should have done the stash and i had to commit the changes. Now what can I do to have

1) the changes from stash back

2) what I got from git pull

3) and my current changes

I found this post here but the person hadn't pulled from master, so I am not sure the answers there would work for me and cannot really risk it and try as it is on master.

like image 654
farm command Avatar asked Dec 16 '16 16:12

farm command


2 Answers

Just use git stash pop or git stash apply. As long as the stashed changes do not conflict with what you pulled or edited, it will just work, if not you get some merge conflicts that you can resolve like when you do a merge or rebase.

like image 62
Vampire Avatar answered Sep 25 '22 10:09

Vampire


$ git stash list            # see stash list(s)  $ git stash apply           # default take the top one 'stash@{0}' $ git stash pop             # pop = apply + drop, take the top stash changes then  delete it    $ git stash apply stash@{1} # get back number 2 stash changes 
like image 40
Sajib Khan Avatar answered Sep 24 '22 10:09

Sajib Khan