Quantcast
Channel: How do I recover a dropped stash in Git? - Stack Overflow
Viewing all articles
Browse latest Browse all 52

Answer by minTwin for How to recover a dropped stash in Git?

$
0
0

This worked for me (in 2022) with recovering my accidently deleted stash in git from a windows environment.

These steps outline how to recover any deleted git stashes or branches (assuming it has not been permanently delete by garbage collection).

  1. Navigate to the directory where your project located.

  2. Enter the command: git fsck --no-reflogs | find "dangling commit"enter image description here

  3. A list of hashes for dangling commits will appear. These will consist of branches and stashes that were deleted. Start with copy and pasting the hashes near the end of the list to find your stash or branch. For example, use the command: git log -1 [hash]

  4. If the corresponding hash matches what you are trying to recover, use the following command to restore it"git stash apply [hash]


Viewing all articles
Browse latest Browse all 52

Trending Articles