Answer the question
In order to leave comments, you need to log in
How to undo git stash apply?
Help sos!! Don't ask me how, but I accidentally git stash apply where I shouldn't. There were a lot of uncommitted edits that are very dear to me, apply stash I did through the php storm interface
Answer the question
In order to leave comments, you need to log in
Hmm... I would try this: Let's
call the latest available commit (0) and the current branch (a).
Since stash apply is done, this element is preserved in the stash (if pop, then you need to conjure with git reflog).
1. Let's make a commit (1a).
2. Go back to commit 0 and create branch "b"
3. Run git stash apply on branch "b"
4. Make a commit (1b)
5. Do a git revert of the previous commit (2b)
6. Move to branch "a" and do git cherry-pick 2b (get commit 2a)
7. If everything is fine, then merge commits 1a and 2a (git rebase -i)
That's it.
In words it is quite simple, but in reality it can be complicated by conflicts, but they are solvable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question