6/19/2023 0 Comments Git stash drop![]() This worked for me: $ git checkout somethingOld In particular, I had stashed something, then checked out an older version, then poped it, but the stash was a no-op at that earlier time point, so the stash disappeared I couldn't just do git stash to push it back on the stack. What I came here looking for is how to actually get the stash back, regardless of what I have checked out. Note: The commit message will only be in this form (starting with "WIP on") if you did not supply a message when you did git stash. WIP on somebranch: commithash Some old commit message To spot stash commits, look for commit messages of this form: You can replace gitk there with something like git log -graph -oneline -decorate if you prefer a nice graph on the console over a separate GUI app. This will launch a repository browser showing you every single commit in the repository ever, regardless of whether it is reachable or not. or see the answer from emragins if using PowerShell for Windows. Otherwise, you can find it using this for Linux, Unix or Git Bash for Windows: git fsck -no-reflog | awk '/dangling commit/ ' ) If you have only just popped it and the terminal is still open, you will still have the hash value printed by git stash pop on screen (thanks, Dolda). When you’re done, just blow the branch away. ![]() ![]() Or, you can create a separate branch for it with git branch recovered $stash_hashĪfter that, you can do whatever you want with all the normal tools. Once you know the hash of the stash commit you dropped, you can apply it as a stash: git stash apply $stash_hash ![]()
0 Comments
Leave a Reply. |