apply gitk fsck awk select-string foreach

Source

  • to find the dropped stash / all unreferenced commits ever
gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $NF}' )
  • or on Windows
gitk --all $( git fsck --no-reflog | select-string 'dangling commit' | foreach { $_.ToString().Split(" ")[-1] } )
  • then look for WIP on somebranch or autostash commit messages
  • once found, note the commit hash
  • to apply the stash run
git stash apply $stash_hash