[英]How to restore deleted file in git if the repository or branch i committed in doesn't exist anymore
請幫助我已經為此工作了一段時間了!!!!
所以我在做一個項目,我開始玩githubDesktop (我能說什么我真的很好奇)並最終刪除了一個存儲庫。一開始我沒有意識到,但是當我打開項目文件夾時,我的大部分時間文件不見了,我只能看到幾個月前的那些,這是最后一次提交。我不知道它是否與分支有關,但它表明我目前處於領先地位。
當我運行 ls 時,它會顯示我刪除的所有文件。(以某種方式錯誤地)
PS C:\Users\curti\Desktop\MFLS> ls
Directory: C:\Users\curti\Desktop\MFLS
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 20/03/2022 10:23 .idea
d----- 04/03/2022 15:03 django-csp
d----- 20/03/2022 09:55 media
d----- 20/03/2022 09:56 MFLS
d----- 20/03/2022 09:56 MFLS_main
d----- 20/03/2022 09:56 registration
-a---- 12/03/2022 17:53 180224 db.sqlite3
-a---- 11/01/2022 14:01 682 manage.py
-a---- 15/01/2022 07:56 164 Pipfile
-a---- 15/01/2022 07:56 4819 Pipfile.lock
像這樣,但我試圖找到已完成的提交,但我找不到,我也找不到任何至少接近今天的提交,這會有所幫助,但我不能它只顯示其他項目的舊提交。當我運行,git log --diff-filter=D --summary 我得到這個:
PS C:\Users\curti\Desktop\MFLS> git log --diff-filter=D --summary
warning: refname 'HEAD' is ambiguous.
warning: refname 'HEAD' is ambiguous.
commit 828d61868e0601152849bef2575c0b4142d51a0e
Author: Curtis Arissol <curtisarissol286@gmail.com>
Date: Wed Aug 4 11:44:03 2021 +0400
having problem with task or to-do bar but partially completed and working
delete mode 100644 classy/index.js
delete mode 100644 classy/views/index.js
commit 8cf9c230ad49a3712151ff109b978bb3288257cd (checking-old-auth)
Author: Curtis Arissol <curtisarissol286@gmail.com>
:
...and other old commits.
注意:我第一次使用 github 桌面時丟失了我的文件 我嘗試轉到 github.com 並恢復存儲庫(即使我不確定那是問題所在)但我不能。
如果你還沒有運行git gc
分支可能已經在你的reflog
中,所以你必須運行git reflog
並記下與刪除分支相關的提交 hash,然后發出git branch <deleted-branch-name> <deleted-branch-last-commit-hash>
來恢復被刪除的分支。
請告訴我它是否解決了您的問題。
問候。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.