{"id":915,"date":"2016-01-21T18:17:04","date_gmt":"2016-01-21T17:17:04","guid":{"rendered":"http:\/\/monodes.com\/predaelli\/?p=915"},"modified":"2016-01-21T15:18:31","modified_gmt":"2016-01-21T14:18:31","slug":"find-and-restore-a-deleted-file-in-a-git-repository","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2016\/01\/21\/find-and-restore-a-deleted-file-in-a-git-repository\/","title":{"rendered":"Find and restore a deleted file in a Git repository"},"content":{"rendered":"<ol>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/953481\/find-and-restore-a-deleted-file-in-a-git-repository\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"size-full alignright\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2016\/01\/apple-touch-icon%402.png?w=910\" alt=\"\" \/><\/a>Use <code class=\"\" data-line=\"\">git log --diff-filter=D --summary<\/code> to get all the commits which have deleted files and the files deleted;<\/li>\n<li>Use <code class=\"\" data-line=\"\">git checkout $commit~1 filename<\/code> to restore the deleted file.<\/li>\n<\/ol>\n<p>Sorgente: <em><a href=\"http:\/\/stackoverflow.com\/questions\/953481\/find-and-restore-a-deleted-file-in-a-git-repository\">Find and restore a deleted file in a Git repository &#8211; Stack Overflow<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Use git log &#8211;diff-filter=D &#8211;summary to get all the commits which have deleted files and the files deleted; Use git checkout $commit~1 filename to restore the deleted file. Sorgente: Find and restore a deleted file in a Git repository &#8211; Stack Overflow<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2016\/01\/21\/find-and-restore-a-deleted-file-in-a-git-repository\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"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,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","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}},"categories":[72],"tags":[51],"class_list":["post-915","post","type-post","status-publish","format-standard","hentry","category-documentations","tag-git"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-eL","jetpack-related-posts":[{"id":11886,"url":"https:\/\/monodes.com\/predaelli\/2024\/09\/01\/git-copy-a-file-or-directory-from-another-repository-preserving-the-history\/","url_meta":{"origin":915,"position":0},"title":"Git: Copy a file or directory from another repository preserving the history","author":"Paolo Redaelli","date":"2024-09-01","format":"quote","excerpt":"How to copy a file or directory from another GIT repository while preserving its history? Internet is full of magic formulas each one more complex. Here I\u2019m proposing a much simpler and faster one that is to make a git format-patch for the entire history of the file or subdirectory\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10940,"url":"https:\/\/monodes.com\/predaelli\/2023\/11\/03\/versioning-data-in-postgres-testing-a-git-like-approach-specfy\/","url_meta":{"origin":915,"position":1},"title":"Versioning data in Postgres? Testing a git like approach &#8211; Specfy","author":"Paolo Redaelli","date":"2023-11-03","format":false,"excerpt":"Versioning data in Postgres? Testing a git like approach - Specfy is fashinating but I think that most of the time these two proposed alternatives fit most of the needs: In-Table versioning, the Wordpress way of doing thing. Add a a column version (or modify date) and SELECT the maximum\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11167,"url":"https:\/\/monodes.com\/predaelli\/2024\/01\/10\/lets-clone-simplemobiletools\/","url_meta":{"origin":915,"position":2},"title":"Let&#8217;s clone SimpleMobileTools","author":"Paolo Redaelli","date":"2024-01-10","format":false,"excerpt":"Since SimpleMobileTools has been sold by its creator to a company notorious for buying apps from developers and repacking them with ads, putting a \"no-ads\" subscription to remove it for $15 a week, the time is ripe to clone its repositories! Join me, I already did it!: git clone https:\/\/github.com\/SimpleMobileTools\/Simple-App-Launcher\u2026","rel":"","context":"In &quot;Ethics&quot;","block_context":{"text":"Ethics","link":"https:\/\/monodes.com\/predaelli\/category\/ethics\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":15483,"url":"https:\/\/monodes.com\/predaelli\/2026\/04\/10\/the-git-commands-i-run-before-reading-any-code\/","url_meta":{"origin":915,"position":3},"title":"The Git Commands I Run Before Reading Any Code","author":"Paolo Redaelli","date":"2026-04-10","format":"link","excerpt":"The Git Commands I Run Before Reading Any Code What Changes the Most Who Built This Where Do Bugs Cluster Is This Project Accelerating or Dying How Often Is the Team Firefighting The Git Commands I Run Before Reading Any Code Five git commands that tell you where a codebase\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":13722,"url":"https:\/\/monodes.com\/predaelli\/2025\/07\/14\/rename-remote-branch-without-deleting-it\/","url_meta":{"origin":915,"position":4},"title":"Rename remote branch without deleting it","author":"Paolo Redaelli","date":"2025-07-14","format":false,"excerpt":"Rename remote branch without deleting it Quick oneliner for deleting old branch and creating a new one with same content is: git push <remote> <remote>\/<old>:refs\/heads\/<new> :<old> where remote is obvious - e.g. origin, old and new are names of branches old and new respectively.","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1518,"url":"https:\/\/monodes.com\/predaelli\/2016\/05\/11\/master-of-cracking\/","url_meta":{"origin":915,"position":5},"title":"Master of cracking","author":"Paolo Redaelli","date":"2016-05-11","format":false,"excerpt":"It seems that I'm a master in breaking automated tests. Do you think I can count it as a proficiency? :) Liberty Eiffel automated tests (Bell branch) Last update: 2016-05-11 11:44:02 +0200 (CEST) git pull failed (1) cd \/Liberty && git fetch origin && git checkout bell && git merge\u2026","rel":"","context":"In &quot;Eiffel&quot;","block_context":{"text":"Eiffel","link":"https:\/\/monodes.com\/predaelli\/category\/eiffel\/"},"img":{"alt_text":"liberty-light","src":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2016\/05\/liberty-light-150x150-1.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=915"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/915\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}