{"id":9479,"date":"2018-02-27T17:20:23","date_gmt":"2018-02-27T16:20:23","guid":{"rendered":"http:\/\/www.b.shuttle.de\/hayek\/hayek\/jochen\/wp\/blog-en\/?p=9479"},"modified":"2018-02-27T17:20:23","modified_gmt":"2018-02-27T16:20:23","slug":"git-find-and-restore-a-deleted-file","status":"publish","type":"post","link":"https:\/\/wp.jochen.hayek.name\/blog-en\/2018\/02\/27\/git-find-and-restore-a-deleted-file\/","title":{"rendered":"Stack Overflow: find and restore a deleted file in a Git repository"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/953481\/find-and-restore-a-deleted-file-in-a-git-repository\">https:\/\/stackoverflow.com\/questions\/953481\/find-and-restore-a-deleted-file-in-a-git-repository<\/a><\/li>\n<\/ul>\n<p>Amongst all the suggestions there I had to find something, that fits my scenario.<\/p>\n<pre>First find the commit ID, that includes the deletion of the resp. file (use either <code>--summary<\/code> or --raw!) (<code>git log<\/code> displays its output through $PAGER, presumably the utility <code>less<\/code>):<\/pre>\n<pre>$ git log --summary # find the file and the commit ID (in the pager)\n$ git log --raw     # find the file and the commit ID (in the pager)<\/pre>\n<p>Now use the <code><em>commit_ID<\/em> <\/code>to specify, that you are interested in\u00a0 a commit to\u00a0<span style=\"text-decoration: underline\">that<\/span> file but <span style=\"text-decoration: underline\">before<\/span> that <em><code>commit_ID<\/code><\/em>, therefore the &#8220;<span style=\"text-decoration: underline\">^<\/span>&#8221; after <em><code>commit_ID<\/code><\/em>:<\/p>\n<pre>$ git checkout <em>commit_ID<\/em>^ THE_FILE<\/pre>\n<p>&#8230;\t\t\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/stackoverflow.com\/questions\/953481\/find-and-restore-a-deleted-file-in-a-git-repository Amongst all the suggestions there I had to find something, that fits my scenario. First find the commit ID, that includes the deletion of the resp. file (use either &#8211;summary or &#8211;raw!) (git log displays its output through $PAGER, presumably the utility less): $ git log &#8211;summary # find the file and the commit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_share_on_mastodon":"0"},"categories":[783],"tags":[],"class_list":["post-9479","post","type-post","status-publish","format-standard","hentry","category-git-scm"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paO0kP-2sT","jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/9479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/comments?post=9479"}],"version-history":[{"count":0,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/9479\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/media?parent=9479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/categories?post=9479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/tags?post=9479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}