[{"data":1,"prerenderedAt":124},["ShallowReactive",2],{"post:restore-deleted-files-from-old-commits":3},{"id":4,"title":5,"body":6,"date":113,"description":12,"draft":114,"extension":115,"meta":116,"navigation":117,"path":118,"seo":119,"stem":120,"tags":121,"__hash__":123},"posts\u002Fposts\u002Frestore-deleted-files-from-old-commits.md","TIL: Restore Deleted Files from Older Commits",{"type":7,"value":8,"toc":108},"minimark",[9,13,18,29,59,66,70,77,95,104],[10,11,12],"p",{},"Ugh. So I saw a bug logged today due to a missing piece of code. What?! That was there yesterday! Turns out I had deleted the file by accident and not realized it.",[14,15,17],"h2",{"id":16},"find-the-commit-which-deleted-the-file","Find the Commit Which Deleted the File",[10,19,20,21,28],{},"This article talks about ",[22,23,27],"a",{"href":24,"rel":25},"http:\u002F\u002Fblog.kablamo.org\u002F2013\u002F12\u002F08\u002Fgit-restore\u002F",[26],"nofollow","How to find and restore deleted files with git",", and wonderfully explains the first step: discovering the offending git commit.",[30,31,36],"pre",{"className":32,"code":33,"language":34,"meta":35,"style":35},"language-bash shiki shiki-themes github-light github-dark","git log --diff-filter=D --summary\n","bash","",[37,38,39],"code",{"__ignoreMap":35},[40,41,44,48,52,56],"span",{"class":42,"line":43},"line",1,[40,45,47],{"class":46},"sScJk","git",[40,49,51],{"class":50},"sZZnC"," log",[40,53,55],{"class":54},"sj4cs"," --diff-filter=D",[40,57,58],{"class":54}," --summary\n",[10,60,61,62,65],{},"This will give you a log of all commits which deleted a file. The ",[37,63,64],{},"--summary"," will also show which files were deleted.",[14,67,69],{"id":68},"restore-the-file-from-the-commit","Restore the file from the commit",[10,71,72,73,76],{},"Given commit ID ",[37,74,75],{},"123x7x",", run this to restore the file(s)",[30,78,80],{"className":32,"code":79,"language":34,"meta":35,"style":35},"git checkout 123x7x~1 myFile\n",[37,81,82],{"__ignoreMap":35},[40,83,84,86,89,92],{"class":42,"line":43},[40,85,47],{"class":46},[40,87,88],{"class":50}," checkout",[40,90,91],{"class":50}," 123x7x~1",[40,93,94],{"class":50}," myFile\n",[10,96,97,98,103],{},"There's also a score of great answers on ",[22,99,102],{"href":100,"rel":101},"https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F953481\u002Ffind-and-restore-a-deleted-file-in-a-git-repository",[26],"this StackOverflow question"," as well.",[105,106,107],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":35,"searchDepth":109,"depth":109,"links":110},2,[111,112],{"id":16,"depth":109,"text":17},{"id":68,"depth":109,"text":69},"2018-05-01T09:10:36-04:00",false,"md",{},true,"\u002Fposts\u002Frestore-deleted-files-from-old-commits",{"title":5,"description":12},"posts\u002Frestore-deleted-files-from-old-commits",[47,122],"til","1pbg74ZuOYql05LaTT7vIK5tDIaDgoqzyQQ1QHba2pQ",1790471528222]