簡體   English   中英

在 `git git filter-repo -> git pull --allow-unrelated-histories` 之后有什么方法可以找回本地歷史記錄?

[英]any way to get back local history after `git git filter-repo -> git pull --allow-unrelated-histories`?

我可能發現了一種不可撤銷地刪除有價值的東西的好方法。 有什么方法可以撤消步驟 1-2 嗎?

背景

  1. 我在提交中有一個大文件導致推送錯誤,所以我嘗試使用以下方法刪除它:
git filter-repo --path <this big file>--invert-paths --force
  1. 我試圖重新推送提交,但 git 拒絕在沒有遠程拉動的情況下這樣做,我是通過以下方式做到的:
git pull origin main --allow-unrelated-histories
  1. 現在,在我的編輯器中打開的幾個文件被標記為丟失,還有更多文件系統中的文件消失或被覆蓋。 這是git reflog的 output
$ git reflog --all 
01eb3b2 (origin/main) refs/remotes/origin/main@{0}: fetch origin: storing head
5ba15dd (HEAD -> main) refs/heads/main@{0}: commit (initial): update before s6, working on laplace alpha coeff
5ba15dd (HEAD -> main) HEAD@{0}: commit (initial): update before s6, working on laplace alpha coeff
  1. 對於上面 (1,2) 未刪除的文件,我實際上可以使用<changed file> (Explorer View)->Open Timeline Visual Studio Code 中未提交更改的歷史記錄。
    在此處輸入圖像描述 但是,我無法對許多新的本地文件執行此操作,這些文件在拉入遙控器時顯然已被刪除 (2)。 有什么辦法嗎?

正如@torek 在評論中所述,我在上面對 git 的使用破壞了新創建的文件,這些文件的唯一歷史記錄在本地存儲庫中被覆蓋。

因此,OP 中描述的 git 命令序列是不可逆的。

然而,下面提到的故障安全可能是連接到 Visual Studio Code 遠程環境的大量用戶的唯一生命線,他們意識到濫用基本 git 命令的后果為時已晚。

VSCode (>= 1.66) 遠程環境的故障安全:

所以事實證明,即使我在遠程開發容器內進行開發, Visual Studio Code 也會在本地緩存自 v.1.66 以來的遠程工作區更改 我所要做的就是Local History: Find Entry to Restore以找到通過 OP 中的git filter-repo命令在遠程文件系統上刪除的文件的更改歷史記錄。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM