Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So here's what happened: I was on a branch 'A' and did a Git stash on that branch. Then I switched to another branch 'B'. I navigated back to Branch 'A' but did not do a Git stash pop. I switched to the master branch and then back to branch 'A'. I am trying to go a git stash pop now but cant seem to get my changes back.. I need to recover that code but whenever I do a git stash pop, my file changes are not listed. I did not commit any code.

Is there a way to recover the changes that I made? would really appreciate any help in this regards.

question from:https://stackoverflow.com/questions/12147042/lost-git-stash-changes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
346 views
Welcome To Ask or Share your Answers For Others

1 Answer

We also faced the same issue. So, here is how we recovered the lost changes:

  1. Go back to branch B.

    git checkout B

  2. Use git reflog option to mange reflog information.

    git reflog --all

    Output:

    f332d5c refs/stash@{0}: WIP on B: aa1d0c1 xyz commit message

  3. Now, switch to branch A using git checkout A

  4. Finally, to recover your lost changes.

    git stash apply f332d5c


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...