{"id":794,"date":"2022-05-15T10:25:05","date_gmt":"2022-05-15T02:25:05","guid":{"rendered":"https:\/\/log.tanxiaodian.com\/?p=794"},"modified":"2022-05-15T10:25:06","modified_gmt":"2022-05-15T02:25:06","slug":"git-%e8%af%af%e5%88%a0%e4%ba%86stash-%e6%80%8e%e4%b9%88%e6%81%a2%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/log.tanxiaodian.com\/?p=794","title":{"rendered":"Git \u8bef\u5220\u4e86stash \u600e\u4e48\u6062\u590d"},"content":{"rendered":"\n<p>\u8f6c\u81ea:<a href=\"https:\/\/blog.csdn.net\/weixin_44388689\/article\/details\/120076830\">(23\u6761\u6d88\u606f) git stash drop \u8bef\u5220\u6062\u590d_RayPick\u7684\u535a\u5ba2-CSDN\u535a\u5ba2_git stash \u6062\u590d<\/a><\/p>\n\n\n\n<p>\u573a\u666f: \u4fdd\u5b58\u4e86stash  \u63d0\u4ea4\u4e86\u5206\u652f \u540e \u9519\u8bef\u4f7f\u7528git stash drop  \u4e4b\u524d\u7684\u4fee\u6539\u4e0d\u89c1\u4e86<\/p>\n\n\n\n<p>\u573a\u666f<br>\u4ee3\u7801\u6b63\u5728\u5f00\u53d1\u4e2d\u4e0d\u60f3commit\uff0c\u4f46\u662f\u8981\u5207\u6362\u5176\u5b83commit\u6216branch\u53bb\u5904\u7406\u4e34\u65f6\u7d27\u6025\u4efb\u52a1,\u4e8e\u662f\u7528git stash \u5907\u4efd\u5f53\u524d\u7684\u5de5\u4f5c\u533a\u7684\u5185\u5bb9\u3002<br>\u5207\u6362\u56de\u6765\u65f6\u4e0d\u5c0f\u5fc3\u4f7f\u7528\u4e86 git stash drop ,\u4e8e\u662f\u6682\u5b58\u7684\u4fee\u6539\u5168\u6ca1\u4e86\u3002<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e00<br>\u81ea\u5df1\u77e5\u9053\u5220\u9664\u7684ID\u53f7<\/p>\n\n\n\n<p>\u7136\u540e\u901a\u8fc7\u547d\u4ee4git fsck \u2013lost-found\u627e\u5230\u6700\u8fd1\u7684\u4e00\u4e9b\u5220\u9664\u7684\u63d0\u4ea4,\u627e\u52309c8223*,\u7136\u540egit show 9c8223\u67e5\u770b\u4fee\u6539\u60c5\u51b5,git stash apply 9c8223\u5373\u53ef\u4fee\u590d\u5220\u9664\u6389\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e8c<br>\u4e0d\u77e5\u9053\u5220\u9664\u7684ID\u53f7\u4f46\u662f\u5927\u6982\u8bb0\u5f97\u81ea\u5df1\u4fee\u6539\u4e86\u54ea\u4e9b\u5185\u5bb9<\/p>\n\n\n\n<p>\u6b65\u9aa4\u4e00\uff1a\u628a\u4fee\u6539\u5185\u5bb9\u5b58\u5165\u6587\u4ef6<\/p>\n\n\n\n<p>git fsck &#8211;lost-found &gt;&gt; 1.txt<br>\u6216<br>git fsck &#8211;unreachable &gt;&gt; 2.txt<br>1<br>2<br>3<br>\u7136\u540e\u4e24\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u683c\u5f0f\u5982\u4e0b<\/p>\n\n\n\n<p>\u6b65\u9aa4\u4e8c\uff1a\u7b5b\u9009\u6307\u5b9a\u7684\u4fe1\u606f\u5e76\u8bb0\u4f4fID\uff0c\u5229\u7528\u811a\u672c\u5feb\u901f\u5b9a\u4f4d\u67e5\u627e<\/p>\n\n\n\n<h1>!\/bin\/sh<\/h1>\n\n\n\n<p>READFILENAME=&#8221;1.txt&#8221; #\u4e0a\u6b65\u6587\u4ef6\u540d\u30101.txt dangling commit\uff0c2.txt\u5bf9\u5e94unreachable commit\u3011<br>RETFILENAME=&#8221;.\/ret.txt&#8221; #\u7b5b\u9009\u7ed3\u679c\u6587\u4ef6\u540d<br>while read -r line<br>do<br>VAR=<code>echo $line | awk '\/dangling commit\/ {print $3}'<\/code><br>if [ $VAR ]; then<br>git show $VAR &gt;&gt; $RETFILENAME<br>echo &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\\n&#8221; &gt;&gt;$RETFILENAME #\u6bcf\u6761\u8bb0\u5f55\u7528&#8212;\u5206\u5272\u5f00<br>fi<br>done &lt; $READFILENAME<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>\u6b65\u9aa4\u4e09\uff1a \u6839\u636e\u6267\u884c\u7ed3\u679c\u627e\u56de\u5220\u9664\u7684\u4ee3\u7801<\/p>\n\n\n\n<p>\u6211\u5220\u9664\u7684\u662fcommit 9c8223257bb39c4975d3407fbfde72241eb76de6<\/p>\n\n\n\n<p>\u6240\u4ee5\u76f4\u63a5 git stash apply 9c8223257bb39c4975d3407fbfde72241eb76de6\u5373\u53ef\u5b8c\u6210\u6062\u590d<br>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<br>\u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3aCSDN\u535a\u4e3b\u300cRayPick\u300d\u7684\u539f\u521b\u6587\u7ae0\uff0c\u9075\u5faaCC 4.0 BY-SA\u7248\u6743\u534f\u8bae\uff0c\u8f6c\u8f7d\u8bf7\u9644\u4e0a\u539f\u6587\u51fa\u5904\u94fe\u63a5\u53ca\u672c\u58f0\u660e\u3002<br>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/blog.csdn.net\/weixin_44388689\/article\/details\/120076830<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u81ea:(23\u6761\u6d88\u606f) git stash drop&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/log.tanxiaodian.com\/?p=794\">Continue reading<span class=\"screen-reader-text\">Git \u8bef\u5220\u4e86stash \u600e\u4e48\u6062\u590d<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[115],"tags":[144],"_links":{"self":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/794"}],"collection":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=794"}],"version-history":[{"count":1,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/794\/revisions"}],"predecessor-version":[{"id":795,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/794\/revisions\/795"}],"wp:attachment":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}