2

附上截图来说明我的意思。2012 年 7 月 12 日至 2013 年 2 月 2 日在这两个日期之间,我使用 GUI 工具丢失了所有工作,不知道如何恢复它们。有人可以帮忙吗?

Git 日志

commit eb64161f29fff57ab861880c4cd1cdf7641c39bf
Author: unknown <DIAMONS@DIAMONS-PC.(none)>
Date:   Fri Dec 7 02:00:10 2012 -0500

A

commit e7850a9c4218b8853b95fff72b08d81c9de1a493
Author: unknown <DIAMONS@DIAMONS-PC.(none)>
Date:   Fri Dec 7 01:59:09 2012 -0500

A

commit 76c81938af7ec183a306e5377ad503b84371dbc7
Author: unknown <DIAMONS@DIAMONS-PC.(none)>
Date:   Fri Dec 7 01:57:27 2012 -0500

A

commit a98041150974116addf1edb867c3481140a16633
Author: unknown <DIAMONS@DIAMONS-PC.(none)>
Date:   Fri Dec 7 01:56:23 2012 -0500

A

Git 参考日志

eb64161 HEAD@{0}: checkout: moving from fe2772d3a363fc7ca348d936bd3a5ac97ccf9dc2
fe2772d HEAD@{1}: checkout: moving from 096491742d37c885ed93db2bb06b3fbe65b69499
0964917 HEAD@{2}: checkout: moving from 6eb9a8e66561d2e72b8391fec823df6d6999cceb
6eb9a8e HEAD@{3}: checkout: moving from master to 6eb9a8e
eb64161 HEAD@{4}: checkout: moving from 4d6a18311433a9bee737eda9bf6114f8bc35fa2c
4d6a183 HEAD@{5}: checkout: moving from 13a4a7e00c15986e07c48969f026afb2fe02f60b
13a4a7e HEAD@{6}: checkout: moving from 4374fecebf215eb868beb881af8909922d45e764
4374fec HEAD@{7}: checkout: moving from 49f004a3d08ee52ee24334c07fc9d35c40480dbb
49f004a HEAD@{8}: checkout: moving from 8e58a900f13132e0dcaa39ae980f7868184cbf65
8e58a90 HEAD@{9}: checkout: moving from 60299f452350c05d22e6bd703f1a7658112c171f
60299f4 HEAD@{10}: checkout: moving from 7e1ae4e7907f446d7d238741933509d4d64e071
7e1ae4e HEAD@{11}: checkout: moving from bec6e9bab96300e4a5d11b5fb1f381659bffe16
bec6e9b HEAD@{12}: checkout: moving from 60299f452350c05d22e6bd703f1a7658112c171
60299f4 HEAD@{13}: checkout: moving from 4d6a18311433a9bee737eda9bf6114f8bc35fa2
4d6a183 HEAD@{14}: checkout: moving from eb64161f29fff57ab861880c4cd1cdf7641c39b
eb64161 HEAD@{15}: checkout: moving from master to eb64161
eb64161 HEAD@{16}: checkout: moving from 4d6a18311433a9bee737eda9bf6114f8bc35fa2
4d6a183 HEAD@{17}: checkout: moving from master to HEAD@{3}
eb64161 HEAD@{18}: checkout: moving from eb64161f29fff57ab861880c4cd1cdf7641c39b
eb64161 HEAD@{19}: checkout: moving from master to master@{2013-01-19}
eb64161 HEAD@{20}: pull: Fast-forward
4d6a183 HEAD@{21}: checkout: moving from 7e1ae4e7907f446d7d238741933509d4d64e071
7e1ae4e HEAD@{22}: checkout: moving from 60299f452350c05d22e6bd703f1a7658112c171
60299f4 HEAD@{23}: checkout: moving from 8e58a900f13132e0dcaa39ae980f7868184cbf6
4

1 回答 1

1

Git 不会立即删除提交和其他对象。因此,如果您的数据已提交,您可以通过检查 last good commit 来获取它们。

浏览您发布的 reflog 并检查每个版本(从最新开始)。迟早你会发现你的数据有一个好的版本。然后将该提交标记为分支 ( git checkout HASH -b my-lost-master)。

编辑1:

另一种选择是以git fsck --lost-found与 reflog 相同的方式运行并检查其输出。

编辑2:

另一个救援工具是这样的:

git rev-list --objects --all \
| awk '{cmd="git cat-file -t "$1;cmd |& getline t; printf("%s %-7s %s\n", $1, t, $2); close(cmd);}' \
| less

它将扫描整个 git 对象存储并在其中描述所有内容。您应该在那长长的列表中的某处看到您的文件。

于 2013-02-05T20:45:31.227 回答