From: W. Trevor King Date: Sat, 22 Jan 2011 15:45:37 +0000 (-0500) Subject: Add notes on restoring deleted files to Git/notes.org. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=895b4904391fa427f87830b68193490db22848e4;p=mw2txt.git Add notes on restoring deleted files to Git/notes.org. --- 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