{"id":258869,"date":"2022-12-25T10:09:03","date_gmt":"2022-12-25T02:09:03","guid":{"rendered":"https:\/\/gulass.cn\/?p=258869"},"modified":"2022-12-11T11:09:51","modified_gmt":"2022-12-11T03:09:51","slug":"git-bisect-commit","status":"publish","type":"post","link":"https:\/\/gulass.cn\/git-bisect-commit.html","title":{"rendered":"Git bisect \u547d\u4ee4\u5e2e\u52a9\u5b9a\u4f4d\u9996\u6b21\u5f15\u5165\u9519\u8bef\u7684\u63d0\u4ea4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nGit \u7684 bisect \u5de5\u5177\u901a\u8fc7\u5feb\u901f\u8bc6\u522b\u574f\u7684\u63d0\u4ea4\uff0c\u8282\u7701\u4e86\u65f6\u95f4\u548c\u7cbe\u529b\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\" <\/p>\n

\u4f60\u662f\u4e0d\u662f\u6709\u8fc7\u8fd9\u6837\u7684\u7ecf\u5386\uff1a\u53d1\u73b0\u4ee3\u7801\u4e2d\u6709 \u9519\u8befbug\uff0c\u4f46\u4e0d\u77e5\u9053\u8fd9\u4e2a\u9519\u8bef\u662f\u4ec0\u4e48\u65f6\u5019\u5f15\u5165\u7684\u3002\u8fd9\u6709\u53ef\u80fd\u662f\u56e0\u4e3a\uff0c\u67d0\u4e2a\u4eba\u63d0\u4ea4\u4e86\u4e00\u4efd\u6709\u9519\u8bef\u7684\u4ee3\u7801\uff0c\u4f46\u6ca1\u6709\u5728\u4ed6\u7684 Git \u63d0\u4ea4commit \u6d88\u606f\u4e2d\u58f0\u660e\u5b83\u3002\u8fd9\u4e2a\u9519\u8bef\u53ef\u80fd\u5df2\u7ecf\u5b58\u5728\u4e86\u51e0\u5468\u3001\u51e0\u4e2a\u6708\u751a\u81f3\u51e0\u5e74\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u9700\u8981\u641c\u7d22\u6570\u767e\u6216\u6570\u5343\u4e2a\u63d0\u4ea4\uff0c\u624d\u80fd\u627e\u5230\u95ee\u9898\u4f55\u65f6\u51fa\u73b0\u7684\u3002\u800c \u200b\u200bgit bisect\u200b\u200b \u547d\u4ee4\u80fd\u591f\u5b8c\u7f8e\u5730\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff01<\/p>\n

\u200b\u200bgit bisect\u200b\u200b \u547d\u4ee4\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u7ed9 \u200b\u200bgit bisect\u200b\u200b \u547d\u4ee4\u4e00\u4e2a\u8303\u56f4\uff0c\u4e00\u7aef\u662f\u4e00\u4e2a\u5df2\u77e5\u7684\u597d\u72b6\u6001\uff0c\u53e6\u4e00\u7aef\u662f\u4e00\u4e2a\u5df2\u77e5\u7684\u574f\u72b6\u6001\u3002\u5b83\u4f1a\u81ea\u52a8\u5730\u786e\u8ba4\u5f53\u524d\u8303\u56f4\u7684\u4e2d\u70b9\uff0c\u5728\u8fd9\u4e2a\u4e2d\u70b9\u4e0a\u8fdb\u884c\u6d4b\u8bd5\uff0c\u7136\u540e\u8981\u6c42\u4f60\u786e\u5b9a\u90a3\u6b21\u63d0\u4ea4\u662f\u4e00\u4e2a \u597d\u63d0\u4ea4good commit \u8fd8\u662f\u4e00\u4e2a \u574f\u63d0\u4ea4bad commit\uff0c\u7136\u540e\u5b83\u4f1a\u91cd\u590d\u8fd9\u4e00\u201c\u4e8c\u5206\u67e5\u627e\u201d\u7684\u8fc7\u7a0b\uff0c\u76f4\u5230\u4f60\u627e\u5230\u9996\u6b21\u5f15\u5165\u9519\u8bef\u7684\u90a3\u4e00\u6b21\u63d0\u4ea4\u3002<\/p>\n

\"\"<\/p>\n

\u8fd9\u4e2a\u201c\u6570\u5b66\u201d\u5de5\u5177\u662f\u5229\u7528\u201c\u4e8c\u5206\u67e5\u627e\u201d\u6765\u627e\u5230\u9519\u8bef\u4e4b\u5904\u7684\u3002\u200b\u200bgit bisect\u200b\u200b \u547d\u4ee4\u901a\u8fc7\u67e5\u770b\u4e2d\u70b9\uff0c\u7136\u540e\u7531\u4f60\u6765\u51b3\u5b9a\u5b83\u662f\u63d0\u4ea4\u5217\u8868\u7684\u65b0\u8d77\u70b9\uff08\u5373 \u201c\u574f\u63d0\u4ea4\u201d \uff09\u8fd8\u662f\u65b0\u7ec8\u70b9\uff08\u5373 \u201c\u597d\u63d0\u4ea4\u201d\uff09\uff0c\u8fdb\u800c\u6765\u7f29\u5c0f\u67e5\u627e\u8303\u56f4\uff0c\u5982\u6b64\u5728\u51e0\u6b21\u67e5\u627e\u4e2d\u4f60\u53ef\u4ee5\u5c31\u80fd\u5b9a\u4f4d\u5230\u6709\u9519\u8bef\u7684\u63d0\u4ea4\u3002\u5373\u4f7f\u4f60\u6709 10,000 \u4e2a\u63d0\u4ea4\u8981\u68c0\u67e5\uff0c\u6700\u591a\u53ea\u9700\u8981 13 \u6b21\u67e5\u627e\uff0c\u5c31\u80fd\u5f88\u5feb\u5730\u5b9a\u4f4d\u5230\u9996\u6b21\u5f15\u5165\u9519\u8bef\u7684\u63d0\u4ea4\u3002<\/p>\n

    \n
  1. \u63d0\u4ea4 1 \u574f <> \u63d0\u4ea4 10,000 \u597d => \u63d0\u4ea4 5,000 \u662f\u574f\u7684<\/li>\n
  2. \u63d0\u4ea4 5,000 \u574f <> \u63d0\u4ea4 10,000 \u597d => \u63d0\u4ea4 7,500 \u662f\u597d\u7684<\/li>\n
  3. \u63d0\u4ea4 5,000 \u574f <> \u63d0\u4ea4 7,500 \u597d => \u63d0\u4ea4 6,250 \u662f\u597d\u7684<\/li>\n
  4. \u63d0\u4ea4 5,000 \u574f <> \u63d0\u4ea4 6,250 \u597d => \u63d0\u4ea4 5,625 \u662f\u574f\u7684<\/li>\n
  5. \u63d0\u4ea4 5,625 \u574f <> \u63d0\u4ea4 6,250 \u597d => \u63d0\u4ea4 5,938 \u662f\u574f\u7684<\/li>\n
  6. \u63d0\u4ea4 5,938 \u574f <> \u63d0\u4ea4 6,250 \u597d => \u63d0\u4ea4 6,094 \u662f\u597d\u7684<\/li>\n
  7. \u63d0\u4ea4 5,938 \u574f <> \u63d0\u4ea4 6,094 \u597d => \u63d0\u4ea4 6,016 \u662f\u574f\u7684<\/li>\n
  8. \u63d0\u4ea4 6,016 \u574f <> \u63d0\u4ea4 6,094 \u597d => \u63d0\u4ea4 6,055 \u662f\u597d\u7684<\/li>\n
  9. \u63d0\u4ea4 6,016 \u574f <> \u63d0\u4ea4 6,055 \u597d => \u63d0\u4ea4 6,036 \u662f\u574f\u7684<\/li>\n
  10. \u63d0\u4ea4 6,036 \u574f <> \u63d0\u4ea4 6,055 \u597d => \u63d0\u4ea4 6,046 \u662f\u574f\u7684<\/li>\n
  11. \u63d0\u4ea4 6,046 \u574f <> \u63d0\u4ea4 6,055 \u597d => \u63d0\u4ea4 6,050 \u662f\u574f\u7684<\/li>\n
  12. \u63d0\u4ea4 6,050 \u574f <> \u63d0\u4ea4 6,055 \u597d => \u63d0\u4ea4 6,053 \u662f\u597d\u7684<\/li>\n
  13. \u63d0\u4ea4 6,053 \u574f <> \u63d0\u4ea4 6,055 \u597d => \u63d0\u4ea4 6,054 \u662f\u597d\u7684<\/li>\n<\/ol>\n

    \u5bf9\u4e8e\u4e0a\u9762\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u80fd\u77e5\u9053 10,000 \u4e2a\u63d0\u4ea4\u4e2d\u7684\u7b2c\u4e00\u4e2a\u9519\u8bef\u63d0\u4ea4\u662f\u7b2c 6053 \u6b21\u63d0\u4ea4\u3002\u5bf9\u4e8e \u200b\u200bgit bisect\u200b\u200b \u547d\u4ee4\uff0c\u6700\u591a\u9700\u8981\u51e0\u5206\u949f\u5c31\u80fd\u5b8c\u6210\u68c0\u7d22\u3002\u4f46\u662f\u5982\u679c\u8981\u4e00\u4e2a\u4e00\u4e2a\u67e5\u627e\u6bcf\u4e2a\u63d0\u4ea4\u662f\u5426\u9519\u8bef\uff0c\u6211\u751a\u81f3\u65e0\u6cd5\u60f3\u8c61\u9700\u8981\u591a\u957f\u65f6\u95f4\u3002<\/p>\n

    \u4f7f\u7528 Git bisect \u547d\u4ee4<\/strong><\/div>\n

    git bisect\u200b\u200b \u547d\u4ee4\u4f7f\u7528\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff1a<\/p>\n

    \uff08LCTT \u8bd1\u6ce8\uff1a\u4f7f\u7528 \u200b\u200bgit bisect start\u200b\u200b \u547d\u4ee4\u6765\u8fdb\u5165 bisect \u6a21\u5f0f\uff0c\u5e76\u4e14\u8be5\u547d\u4ee4\u6307\u5b9a\u4e86\u4e00\u4e2a\u68c0\u67e5\u8303\u56f4\u3002\u5b83\u4f1a\u544a\u8bc9\u6211\u4eec\u4e00\u5171\u6709\u591a\u5c11\u6b21\u63d0\u4ea4\uff0c\u5927\u6982\u9700\u8981\u51e0\u6b65\u5c31\u53ef\u4ee5\u5b9a\u4f4d\u5230\u5177\u4f53\u7684\u63d0\u4ea4\u3002\uff09<\/p>\n

    \r\n$ git bisect start$ git bisect bad        # Git assumes you mean HEAD by default$ git bisect good  # specify a tag or commit ID for <\/ref>\r\n<\/ref><\/pre>\n

    Git \u68c0\u67e5\u4e2d\u95f4\u7684\u63d0\u4ea4\uff0c\u5e76\u7b49\u5f85\u4f60\u58f0\u660e\u8fd9\u6b21\u63d0\u4ea4\u662f\u4e00\u4e2a\u597d\u63d0\u4ea4\u8fd8\u662f\u4e00\u4e2a\u574f\u63d0\u4ea4\uff1a<\/p>\n

    \uff08LCTT \u8bd1\u6ce8\uff1a\u5982\u679c\u67d0\u4e00\u63d0\u4ea4\u662f\u53ef\u4ee5\u901a\u8fc7\u7684\uff0c\u5219\u4f7f\u7528 \u200b\u200bgit bisect good\u200b\u200b \u547d\u4ee4\u6807\u8bb0\uff1b\u540c\u6837\u5730\uff0c\u5982\u679c\u67d0\u4e00\u63d0\u4ea4\u4e0d\u80fd\u901a\u8fc7\uff0c\u5219\u4f7f\u7528 \u200b\u200bgit bisect bad\u200b\u200b \u547d\u4ee4\u6807\u8bb0\u3002\uff09<\/p>\n

    \r\n$ git bisect good\r\n<\/pre>\n

    \u6216<\/p>\n

    \r\n$ git bisect bad\r\n<\/pre>\n

    \u7136\u540e\uff0c\u200b\u200bgit bisect\u200b\u200b \u5de5\u5177\u91cd\u590d\u68c0\u67e5\u597d\u63d0\u4ea4\u548c\u574f\u63d0\u4ea4\u4e2d\u95f4\u7684\u90a3\u6b21\u63d0\u4ea4\uff0c\u76f4\u5230\u4f60\u544a\u8bc9\u5b83\uff1a<\/p>\n

    \r\n$ git bisect reset\r\n<\/pre>\n

    \u4e00\u4e9b\u9ad8\u7ea7\u7528\u6237\u751a\u81f3\u53ef\u4ee5\u81ea\u5df1\u7f16\u5199\u811a\u672c\uff0c\u6765\u786e\u5b9a\u63d0\u4ea4\u7684\u597d\u574f\u72b6\u6001\u3001\u5e76\u5728\u627e\u5230\u7279\u5b9a\u63d0\u4ea4\u65f6\u91c7\u53d6\u67d0\u4e00\u8865\u6551\u63aa\u65bd\u3002\u4f60\u53ef\u80fd\u4e0d\u4f1a\u6bcf\u5929\u90fd\u4f7f\u7528 \u200b\u200bgit bisect\u200b\u200b \u547d\u4ee4\uff0c\u4f46\u5f53\u4f60\u9700\u8981\u5b83\u6765\u5b9a\u4f4d\u9996\u6b21\u5f15\u5165\u9519\u8bef\u7684\u63d0\u4ea4\u65f6\uff0c\u5b83\u4f1a\u662f\u4e00\u4e2a\u5f88\u6709\u7528\u7684\u6551\u661f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u4f60\u662f\u4e0d\u662f\u6709\u8fc7\u8fd9\u6837\u7684\u7ecf\u5386\uff1a\u53d1\u73b0\u4ee3\u7801\u4e2d\u6709 \u9519\u8befbug\uff0c\u4f46\u4e0d\u77e5\u9053\u8fd9\u4e2a\u9519\u8bef\u662f\u4ec0\u4e48\u65f6\u5019\u5f15\u5165\u7684\u3002\u8fd9\u6709\u53ef\u80fd\u662f\u56e0\u4e3a\uff0c\u67d0\u4e2a\u4eba\u63d0\u4ea4 […]<\/p>\n","protected":false},"author":317,"featured_media":231560,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-258869","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/258869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=258869"}],"version-history":[{"count":3,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/258869\/revisions"}],"predecessor-version":[{"id":259203,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/258869\/revisions\/259203"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/231560"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=258869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=258869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=258869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}