Add notes on restoring deleted files to Git/notes.org.
authorW. Trevor King <wking@drexel.edu>
Sat, 22 Jan 2011 15:45:37 +0000 (10:45 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 22 Jan 2011 15:45:37 +0000 (10:45 -0500)
posts/Git/notes.org

index 3c332febb856edc6dd8e1de4a8b86b56ee1335b8..b0a544af586b1216d7fb1ece3c85fc5b925042d1 100644 (file)
@@ -505,6 +505,21 @@ you can purge the fetched tags and objects with
     : $ git remote rm bob
     : $ git remote prune bob
 
+** Restore a deleted file to match an earlier version
+Source: [[http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo][stackoverflow]].
+
+Find the commit that deleted the file in question
+
+    : $ git rev-list -n 1 HEAD -- <file_path>
+
+or
+
+    : $ git log --diff-filter=D --summary
+
+Then checkout the file
+
+    : $ git checkout <deleting_commit>^ -- <file_path>
+
 ** Move master.HEAD to a different location
 
 Sometimes you screw up and want to drop the thread you've been working