0

I applied a stash and then made several commits. After that, I decided to do a quick look at the stash again. So I typed:

git stash apply stash@{0}

I just wanted to see and did nothing. Now I just want to go back to my latest commit. When I do

git checkout master

It gives error message

error: you need to resolve your current index first
test.js: needs merge

So in this condition, how to go back to my latest commit? I also want to know how to check old stash the right way.

Willy
  • 23
  • 1
  • 6
  • i think this might be it: [How to reverse apply a stash?](https://stackoverflow.com/questions/1020132/how-to-reverse-apply-a-stash) Dit yout tried it already? – Nuno Lucas Feb 05 '18 at 11:42
  • You can try Soft resetting your head to previous commit – Arun Gowda Feb 05 '18 at 12:09
  • this is generic thing whenever you checkout your current state must be clean meaning you need to commit/stash your changes, resolve your conflicts. Try resolving conflict then try checkout it should work – recursion Feb 05 '18 at 13:11

1 Answers1

0

Use the following to reverse apply the stash : Retrieve the stash patch and apply in reverse

git stash show -p stash@{0} | git apply -R

Or try

git reset --merge and see if you can revert from the new state.

Priya Jain
  • 795
  • 5
  • 15
  • Looks like test.js file has some change in your local other than what's there in the stash – Priya Jain Feb 05 '18 at 17:35
  • Just try to stash whatever is there and then you can checkout master branch. Once no error, delete the stash you just saved. A hacky way if you don't care about what extra changes are there in test.js – Priya Jain Feb 05 '18 at 17:38