{"id":7601,"date":"2015-11-22T23:34:20","date_gmt":"2015-11-22T15:34:20","guid":{"rendered":"http:\/\/jpuyy.com\/?p=7601"},"modified":"2026-04-05T18:40:33","modified_gmt":"2026-04-05T10:40:33","slug":"git-%e6%b8%85%e7%90%86-dangle-objects","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=7601","title":{"rendered":"git fsck \u6e05\u7406 dangle objects"},"content":{"rendered":"<p>\u7ecf\u5e38 commit &#8211;amend\uff0cmerge\uff0crebase\uff0creset &#8211;hard \u540e\uff0c\u4f1a\u4ea7\u751f\u4e00\u4e9b\u6ca1\u6709\u5f15\u7528\u7684 objects\uff0c\u8fd9\u4e9b\u6709\u7684\u53ef\u80fd\u4f1a\u6062\u590d\u4f60\u8bef\u64cd\u4f5c\u540e\u7684\u4fee\u6539\uff0c\u4f46\u662f\u5927\u90e8\u5206\u65f6\u95f4\u662f\u6ca1\u7528\u7684\u3002\u60f3\u7740\u6e05\u7406\u4e00\u4e0b\u3002<\/p>\n<p>\u5148\u67e5\u770b\u6709\u54ea\u4e9b<\/p>\n<pre>git fsck --full<\/pre>\n<p>Dangling blob = A change that made it to the staging area\/index, but never got committed. One thing that is amazing with Git is that once it gets added to the staging area, you can always get it back because these blobs behave like commits in that they have a hash too!!<\/p>\n<p>Dangling commit = A commit that isn&#8217;t directly linked to by any child commit, branch, tag or other reference. You can get these back too!<\/p>\n<p>Dangling tree <\/p>\n<p>\u7136\u540e\u67e5\u770b\u5df2\u7ecf\u6ca1\u6709\u7684\u5f15\u7528<\/p>\n<pre>git reflog expire --expire=now --all<\/pre>\n<p>git reflog: record when refs were update in the local repository, useful for recovering lost commits<\/p>\n<p>\u6e05\u7406<\/p>\n<pre>git gc --prune=now<\/pre>\n<p>git gc: clean up and optimize the local repository<\/p>\n<p>\u53c2\u8003\uff1a<br \/>\nhttp:\/\/www.tekkie.ro\/news\/howto-remove-all-dangling-commits-from-your-git-repository\/<br \/>\nhttps:\/\/git-scm.com\/docs\/git-fsck<br \/>\nhttps:\/\/git-scm.com\/book\/en\/v2\/Git-Internals-Maintenance-and-Data-Recovery<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ecf\u5e38 commit &#8211;amend\uff0cmerge\uff0crebase\uff0creset &#8211;hard \u540e\uff0c\u4f1a\u4ea7\u751f\u4e00\u4e9b\u6ca1\u6709\u5f15\u7528\u7684 objects\uff0c\u8fd9\u4e9b\u6709\u7684\u53ef\u80fd\u4f1a\u6062\u590d\u4f60\u8bef\u64cd\u4f5c\u540e\u7684\u4fee\u6539\uff0c\u4f46\u662f\u5927\u90e8\u5206\u65f6\u95f4\u662f\u6ca1\u7528\u7684\u3002\u60f3\u7740\u6e05\u7406\u4e00\u4e0b\u3002 \u5148\u67e5\u770b\u6709\u54ea\u4e9b git fsck &#8211;full Dangling blob = A change that made it to the staging area\/index, but never got committed. One thing that is amazing with Git is that once it gets added to the staging area, you can always get it back because these blobs behave like commits [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-7601","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7601"}],"version-history":[{"count":4,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7601\/revisions"}],"predecessor-version":[{"id":10047,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7601\/revisions\/10047"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}