How to recover a dropped stash in Git?

前端 未结 19 2126
别跟我提以往
别跟我提以往 2020-11-22 01:42

I frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday I had some changes in my working tree that I

19条回答
  •  Happy的楠姐
    2020-11-22 01:53

    You can achieve this in 2 easy steps

    1. List lost stashes --> run this command for a project where all stashes were trashed:

      git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git log --merges --no-walk

    2. Send a lost stash back where it comes from --> Let’s use the commit hash of the second stash:

      git update-ref refs/stash 4b3fc45c94caadcc87d783064624585c194f4be8 -m "My recovered stash"

提交回复
热议问题