恢复误删除的git stash记录 (how to retrieve a deleted git stash)

1.场景:使用git stash或者sourcetree贮藏了工作现场,然后被误删除了这个stash 

2.恢复方法:

a.首先使用git fsck --unreachable命令查找所有unreachable记录,记录的样子大概是这样子的:

unreachable commit 3cf816eeb0dc339513c63dd041e5f4efc6241e24
unreachable commit f318453870754947fe46cf5dfd022bdf33f9c3fd
unreachable blob 5899fee2b9250f6736c256cb88e4c48a6c7f730f
unreachable blob 5e7a445de083dfd9ccd5052b334078eea487fef5
unreachable blob 6dfa8dab7515fe193de7915051ef76799c2c0a6b
unreachable blob d17b6724d17fdf4163fce24c2c881b840d5a7104
unreachable commit 18bcdd17b406e83b53baa693bedbdfebc888b7f6
unreachable commit 7c7c88905b5887ab126759ba13dec58f6c66facc
unreachable blob 82fc409a5de65fc33e29127ca5038e65657777f1
unreachable commit 937cda54033fb5bed77c45faf4cfeef4ef0c14f3
unreachable commit 61bd560936a99d8d8c4dd3d3f91b5d81c05f9c01
unreachable commit 831d76e77ebdcb4d9a5c3d60922790c6fbd4c488
unreachable commit 589e3c800b34e97e320abe375b53e89121c06e48
unreachable commit 749e99d0772094a081443e726eff8b561071ca5d
unreachable commit 683ff00bd7a51e03faa02d6ba0946828c3bfa9a8
unreachable blob ef1f6af9bbb4ffb8ee8dcfc51bf2188375c72669


b.第二步,使用git show +命令会查找你需要恢复的那一条工作现场,sha是上面的key,我们恢复的时候只能恢复unreachable commit 开头的记录,unreach blob是不能用git statsh apply+来恢复的,会报not a stash-like commit 错误


c.使用git stash apply +<你找到的那条记录的key>恢复即可。



你可能感兴趣的:(android,开发)