Quantcast
Viewing latest article 24
Browse Latest Browse All 52

Answer by Changdae Park for How do I recover a dropped stash in Git?

To see only stash commits, where they attached, and what their contents are

result sample

Checking object directories: 100% (256/256), done.2022-08-31 10:20:46 +0900 8d02f61 WIP on master: 243b594 add cssA       favicon.ico

command

git fsck --dangling | awk '/dangling commit/ {print $3}' | xargs -L 1 git --no-pager show -s --format="%ct %h" | sort | awk '{print $2}' | { while read hash; do status=$(git stash show $hash --name-status 2>/dev/null); if (( $? == 0 )); then git show $hash -s --format="%C(green)%ci %C(yellow)%h %C(blue)%B"; echo "$status"; fi; done; }
  • To see full hash, change %h to %H
  • To reduce time, tail fsck like git fsck --dangling | tail -100 | awk ...

recover sampleImage may be NSFW.
Clik here to view.
enter image description here


Viewing latest article 24
Browse Latest Browse All 52

Trending Articles