5

I've been working on a project for months now with regular commits. I use Heroku to store my app. I pushed to Heroku, and then I used the Git GUI to roll back my files to December 7th, and I then force pushed that to Heroku. I was trying to restore a specific folder but did not realize it would restore the whole directory.

I then realized I lost all my commits from December 7th and forward.

I've tried git lost-found and my directory has about 20 heads in the reflog. There is a specific commit I am looking for, I have the hash from Heroku. It is 8d4f84a, but when I do git checkout 8d4f84a it gives me error "Unknown revision or path not found in the working tree."

I did a heroku rollback, and that restored my files on Heroku to the previous push, but I cannot clone those files.

Have I lost all my work up this point?

EDIT: Attached reflog, full of old commits dating to December 7th and back

eb64161 HEAD@{0}: checkout: moving from 4d6a18311433a9bee737eda9bf6114f8bc35fa2c
4d6a183 HEAD@{1}: checkout: moving from master to HEAD@{3}
eb64161 HEAD@{2}: checkout: moving from eb64161f29fff57ab861880c4cd1cdf7641c39bf
eb64161 HEAD@{3}: checkout: moving from master to master@{2013-01-19}
eb64161 HEAD@{4}: pull: Fast-forward
4d6a183 HEAD@{5}: checkout: moving from 7e1ae4e7907f446d7d238741933509d4d64e0715
7e1ae4e HEAD@{6}: checkout: moving from 60299f452350c05d22e6bd703f1a7658112c171f
60299f4 HEAD@{7}: checkout: moving from 8e58a900f13132e0dcaa39ae980f7868184cbf65
8e58a90 HEAD@{8}: checkout: moving from 49f004a3d08ee52ee24334c07fc9d35c40480dbb
49f004a HEAD@{9}: checkout: moving from 4374fecebf215eb868beb881af8909922d45e764
4374fec HEAD@{10}: checkout: moving from 13a4a7e00c15986e07c48969f026afb2fe02f60
13a4a7e HEAD@{11}: checkout: moving from master to 13a4a7e00c15986e07c48969f026a
4d6a183 HEAD@{12}: reset: moving to HEAD@{20}
6eb9a8e HEAD@{13}: reset: moving to HEAD@{1}
0964917 HEAD@{14}: reset: moving to HEAD~1
6eb9a8e HEAD@{15}: reset: moving to HEAD~1
e6474e3 HEAD@{16}: reset: moving to HEAD~1
821fe87 HEAD@{17}: reset: moving to HEAD~1
04bd607 HEAD@{18}: reset: moving to HEAD~1
4173f0d HEAD@{19}: reset: moving to HEAD~1
6f15ad8 HEAD@{20}: reset: moving to HEAD~1
a847ccd HEAD@{21}: reset: moving to HEAD~1
498d2e7 HEAD@{22}: reset: moving to HEAD~1
fe2772d HEAD@{23}: reset: moving to HEAD~1
4

3 回答 3

6

是的,你可以这样做,打开 git 控制台并输入

git reflog 

之后你会得到你的提交列表

git reset --hard "hash of commit which you need"
于 2015-09-14T12:36:46.610 回答
3

If you want your new HEAD to be 8d4f84a, then do

git reset --hard 8d4f84a

Resetting also works that direction.

于 2013-02-02T07:10:45.397 回答
3

git reflog显示曾经创建的所有提交对象的历史记录。我猜一个已删除的提交对象的生命周期是 60 天。因此,如果提交不旧,那么您可能可以执行类似git cherry-pick your-commit-hash. git show可用于在挑选代码之前检查代码。希望这可以帮助。

于 2013-02-03T11:38:58.200 回答