Restoring deleted files in Git: Difference between revisions

Jump to navigation Jump to search
m
(Created page with "= 復原 GIT 誤刪除的檔案 = == 復原方法 == === 方法一:透過 Fork 右鍵選單 === 使用 [https://git-fork.com/ Fork Git 客戶端軟體],並且對 <code>Deleted.file</code> 右鍵選擇了 '''Reset File to'''。 # 右鍵點擊被刪除的檔案 # 選擇 '''Reset File to''' → <code>State at Commit...</code> 或 <code>State Before Commit...</code> #* <code>State at Commit...</code> → 還原到某個特定 commit 的狀態 #* <code>State Before Co...")
 
Line 18: Line 18:
> '''注意:''' 檔案路徑需要完全一樣(大小寫、目錄層級都要一致)。
> '''注意:''' 檔案路徑需要完全一樣(大小寫、目錄層級都要一致)。


# 從最新 commit 還原
1. 從最新 commit 還原
<pre lang="bash">
<pre lang="bash">
git checkout HEAD -- sub_folder/Deleted.file
git checkout HEAD -- sub_folder/Deleted.file
</pre>
</pre>


# 或從特定 commit 還原(用 commit hash)
2. 或從特定 commit 還原(用 commit hash)
<pre lang="bash">
<pre lang="bash">
git checkout <commit_hash> -- sub_folder/Deleted.file
git checkout <commit_hash> -- sub_folder/Deleted.file

Navigation menu