From 895b4904391fa427f87830b68193490db22848e4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 22 Jan 2011 10:45:37 -0500 Subject: [PATCH] Add notes on restoring deleted files to Git/notes.org. --- posts/Git/notes.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/posts/Git/notes.org b/posts/Git/notes.org index 3c332fe..b0a544a 100644 --- a/posts/Git/notes.org +++ b/posts/Git/notes.org @@ -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 -- + +or + + : $ git log --diff-filter=D --summary + +Then checkout the file + + : $ git checkout ^ -- + ** Move master.HEAD to a different location Sometimes you screw up and want to drop the thread you've been working -- 2.26.2