How to recover a dropped stash in Git?

前端 未结 19 1754
别跟我提以往
别跟我提以往 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条回答
  •  梦谈多话
    2020-11-22 02:06

    Recovered it by using following steps:

    1. Identify the deleted stash hash code:

      gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

    2. Cherry Pick the Stash:

      git cherry-pick -m 1 $stash_hash_code

    3. Resolve Conflicts if any using:

      git mergetool

    Additionally you might be having issues with commit message if you are using gerrit. Please Stash your changes before following next alternatives:

    1. Use hard reset to previous commit and then recommit this change.
    2. You may also stash the change, rebase and recommit.

提交回复
热议问题