gpt4 book ai didi

git - 恢复 Git 删除的文件(重置 --hard 删除的文件)

转载 作者:行者123 更新时间:2023-12-04 18:33:12 30 4
gpt4 key购买 nike

犯了错误,是的。
我的应用程序的存储文件夹已提交到我的存储库,当我尝试同步提交到存储库并发送到服务器的新更新时,我运行了 git reset --hard && git clean -df .
我几乎不知道存储文件夹中不在我之前提交中的任何文件(存储文件夹已提交 WITH 文件) - 将被删除。

forge@onaxim-crm:~/api.crm.onaxim.com.au$ git reset --hard && git clean -df
Checking out files: 100% (1049/1049), done.
HEAD is now at 6776b4d v2.3updates
Removing storage/customers/1/
Removing storage/customers/1017/
Removing storage/customers/1032/
Removing storage/customers/1039/
Removing storage/customers/1044/
Removing storage/customers/1058/
Removing storage/customers/1084/
Removing storage/customers/1086/
Removing storage/customers/1094/
Removing storage/customers/1095/
Removing storage/customers/1101/
Removing storage/customers/1102/
Removing storage/customers/1106/
Removing storage/customers/1109/
Removing storage/customers/1111/
Removing storage/customers/1112/
Removing storage/customers/1113/
Removing storage/customers/1114/
Removing storage/customers/1115/
Removing storage/customers/1116/
Removing storage/customers/1117/
我检查了目录并且该字段已被删除,所以有什么办法可以恢复它们?
我读了一些关于可能使用 git fsck --lost-found ?

最佳答案

一个 git reset --hard不会将 HEAD 移动到不同的提交,因此如果同步涉及 pull ,您可能仍会在上一个提交( pull 之前的提交)中看到您的内容,用于测试:

git restore @~ -- .

My storage folder of my application was committed to my repo


如果通过“ promise ”,你的意思只是“ git add ”(但没有实际的 git commit ),那么是的,一个 git fsck --cache --no-reflogs --lost-found --unreachable HEAD 需要开始检查已删除暂存文件的内容。
OP Tim Rowley确实提到了 in the comments :

About half of the /storage/customer/xxxx folders are actually in the GitHub repo online from a previous commit.
The other half has never been committed or pushed as they have only been on the server. Thus, I must have accidentally made a push from my server with the first half - and the second half was new. I need the second half back.
The second half never interacted with Git, s


在这种情况下,只有 file recovery tools可能有助于恢复这些文件。

关于git - 恢复 Git 删除的文件(重置 --hard 删除的文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66166711/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com