sách gpt4 ai đã đi

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

In lại 作者:行者123 更新时间:2023-12-04 18:33:12 30 4
mua khóa gpt4 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 ?

1 Câu trả lời

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

git restore @~ -- .

My storage folder of my application was committed to my repo


如果通过“ promise ”,你的意思只是“ git thêm ”(但没有实际的 cam kết git ),那么是的,一个 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
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com