{"id":57307,"date":"2025-08-15T10:29:36","date_gmt":"2025-08-15T02:29:36","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/57307.html"},"modified":"2025-08-15T10:29:36","modified_gmt":"2025-08-15T02:29:36","slug":"%e9%9d%a2%e8%af%95%e5%ae%98%e6%9c%80%e7%88%b1%e9%97%ae%e7%9a%84-10-%e4%b8%aa-git-%e5%91%bd%e4%bb%a4%ef%bc%8c%e7%ad%94%e5%ae%8c%e7%9b%b4%e6%8e%a5%e5%8a%a0%e5%88%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/57307.html","title":{"rendered":"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206"},"content":{"rendered":"<p>\u522b\u518d\u53ea\u4f1a git pull&#xff01;\u7528\u5bf9\u547d\u4ee4\u80fd\u7701\u6389 80% \u7684\u5408\u5e76\u51b2\u7a81\u3001\u8bef\u63d0\u4ea4\u548c\u56de\u6eda\u64cd\u4f5c\u3002<br \/>\n\u4e0b\u9762 10 \u6761\u547d\u4ee4 &#043; 1 \u5f20\u901f\u67e5\u8868&#xff0c;\u590d\u5236\u5373\u53ef\u7528&#xff0c;\u4eca\u665a\u4e0b\u73ed\u65e9&#xff01;<\/p>\n<hr \/>\n<h3>1\ufe0f\u20e3 stash&#xff1a;\u5de5\u4f5c\u533a\u201c\u5feb\u7167\u201d&#xff0c;\u968f\u65f6\u5207\u6362\u5206\u652f\u4e0d\u4e22\u4ee3\u7801<\/h3>\n<p><span class=\"token function\">git<\/span> stash push <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;WIP: \u767b\u5f55\u6a21\u5757&#034;<\/span><br \/>\n<span class=\"token function\">git<\/span> checkout feature<br \/>\n<span class=\"token function\">git<\/span> stash pop        <span class=\"token comment\"># \u56de\u5230\u539f\u5206\u652f\u4ee3\u7801<\/span><\/p>\n<hr \/>\n<h3>2\ufe0f\u20e3 reflog&#xff1a;\u8bef\u5220\u5206\u652f\/\u5f3a\u63a8\u540e\u6094\u836f<\/h3>\n<p><span class=\"token function\">git<\/span> reflog           <span class=\"token comment\"># \u5217\u51fa HEAD \u53d8\u66f4\u5386\u53f2<\/span><br \/>\n<span class=\"token function\">git<\/span> reset <span class=\"token parameter variable\">&#8211;hard<\/span> HEAD&#064;<span class=\"token punctuation\">{<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">}<\/span>  <span class=\"token comment\"># \u56de\u5230 3 \u6b65\u524d<\/span><\/p>\n<hr \/>\n<h3>3\ufe0f\u20e3 bisect&#xff1a;\u4e8c\u5206\u6cd5\u5b9a\u4f4d BUG \u63d0\u4ea4<\/h3>\n<p><span class=\"token function\">git<\/span> bisect start<br \/>\n<span class=\"token function\">git<\/span> bisect bad       <span class=\"token comment\"># \u5f53\u524d\u6709 bug<\/span><br \/>\n<span class=\"token function\">git<\/span> bisect good v1.0 <span class=\"token comment\"># \u5df2\u77e5\u7a33\u5b9a\u7248\u672c<\/span><br \/>\n<span class=\"token comment\"># Git \u81ea\u52a8\u5207\u6362\u63d0\u4ea4&#xff0c;\u6d4b\u8bd5\u540e\u6807\u8bb0 good\/bad<\/span><\/p>\n<hr \/>\n<h3>4\ufe0f\u20e3 cherry-pick&#xff1a;\u53ea\u5408\u5e76\u67d0\u4e00\u6761\u63d0\u4ea4<\/h3>\n<p><span class=\"token function\">git<\/span> cherry-pick a1b2c3d  <span class=\"token comment\"># \u628a\u67d0\u6761\u63d0\u4ea4\u642c\u8fc7\u6765&#xff0c;\u4e0d\u5408\u5e76\u6574\u4e2a\u5206\u652f<\/span><\/p>\n<hr \/>\n<h3>5\ufe0f\u20e3 rebase -i&#xff1a;\u4ea4\u4e92\u5f0f\u6574\u7406\u63d0\u4ea4\u5386\u53f2<\/h3>\n<p><span class=\"token function\">git<\/span> rebase <span class=\"token parameter variable\">-i<\/span> HEAD~3   <span class=\"token comment\"># \u5408\u5e76\/\u91cd\u6392\u6700\u8fd1 3 \u6761\u63d0\u4ea4<\/span><br \/>\n<span class=\"token comment\"># \u7f16\u8f91\u5668\u91cc\u628a pick \u6539\u6210 squash\/fixup<\/span><\/p>\n<hr \/>\n<h3>6\ufe0f\u20e3 worktree&#xff1a;\u4e00\u4efd\u4ed3\u5e93&#xff0c;\u591a\u5957\u5de5\u4f5c\u76ee\u5f55<\/h3>\n<p><span class=\"token function\">git<\/span> worktree <span class=\"token function\">add<\/span> <span class=\"token punctuation\">..<\/span>\/hotfix main  <span class=\"token comment\"># \u5e76\u884c\u5f00\u53d1&#xff0c;\u4e0d\u5207\u6362\u5206\u652f<\/span><\/p>\n<hr \/>\n<h3>7\ufe0f\u20e3 blame&#xff1a;\u4e00\u79d2\u627e\u5230\u201c\u8087\u4e8b\u8005\u201d<\/h3>\n<p><span class=\"token function\">git<\/span> blame src\/index.js <span class=\"token parameter variable\">-L<\/span> <span class=\"token number\">50,60<\/span>  <span class=\"token comment\"># \u67d0\u884c\u4ee3\u7801\u662f\u8c01\u5199\u7684<\/span><\/p>\n<hr \/>\n<h3>8\ufe0f\u20e3 filter-branch&#xff1a;\u6279\u91cf\u5220\u9664\u654f\u611f\u6587\u4ef6<\/h3>\n<p><span class=\"token function\">git<\/span> filter-branch <span class=\"token parameter variable\">&#8211;force<\/span> &#8211;index-filter <span class=\"token punctuation\">\\\\<\/span><br \/>\n<span class=\"token string\">&#039;git rm &#8211;cached &#8211;ignore-unmatch secrets.json&#039;<\/span> <span class=\"token parameter variable\">&#8211;all<\/span><\/p>\n<hr \/>\n<h3>9\ufe0f\u20e3 rerere&#xff1a;\u81ea\u52a8\u89e3\u51b3\u91cd\u590d\u51b2\u7a81<\/h3>\n<p><span class=\"token function\">git<\/span> config rerere.enabled <span class=\"token boolean\">true<\/span>   <span class=\"token comment\"># \u4e00\u6b21\u89e3\u51b3&#xff0c;\u7ec8\u8eab\u53d7\u76ca<\/span><\/p>\n<hr \/>\n<h3>&#x1f51f; alias&#xff1a;\u628a\u7e41\u7410\u547d\u4ee4\u8d77\u5916\u53f7<\/h3>\n<p><span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> alias.graph <span class=\"token string\">&#034;log &#8211;oneline &#8211;graph &#8211;all&#034;<\/span><br \/>\n<span class=\"token function\">git<\/span> graph   <span class=\"token comment\"># \u4e00\u884c\u770b\u61c2\u5206\u652f\u6811<\/span><\/p>\n<hr \/>\n<h3>\u4e00\u952e\u901f\u67e5\u8868&#xff08;\u6253\u5370\u8d34\u5c4f&#xff09;<\/h3>\n<table>\n<tr>\u573a\u666f\u547d\u4ee4<\/tr>\n<tbody>\n<tr>\n<td>\u4e34\u65f6\u5207\u5206\u652f<\/td>\n<td>git stash &amp;&amp; git checkout xxx &amp;&amp; git stash pop<\/td>\n<\/tr>\n<tr>\n<td>\u56de\u6eda\u8bef\u63d0\u4ea4<\/td>\n<td>git reset &#8211;soft HEAD~1 \u6216 git reflog<\/td>\n<\/tr>\n<tr>\n<td>\u5408\u5e76\u5355\u6761\u63d0\u4ea4<\/td>\n<td>git cherry-pick &lt;hash&gt;<\/td>\n<\/tr>\n<tr>\n<td>\u6574\u7406\u5386\u53f2<\/td>\n<td>git rebase -i HEAD~n<\/td>\n<\/tr>\n<tr>\n<td>\u5e76\u884c\u5f00\u53d1<\/td>\n<td>git worktree add ..\/hotfix main<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e00\u53e5\u8bdd\u603b\u7ed3<\/h3>\n<p>\u5b66\u4f1a stash\/rebase\/cherry-pick\/worktree&#xff0c;\u5408\u5e76\u51b2\u7a81\u3001\u56de\u6eda\u3001\u5e76\u884c\u5f00\u53d1 3 \u6b65\u641e\u5b9a&#xff0c;Git \u4e0d\u518d\u53ea\u662f pull\/commit\/push\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb139\u6b21\u3002\u9664 pull\/commit\/push \u5916\uff0cstash\u3001rebase\u3001worktree \u7b49 10 \u4e2a Git \u51b7\u95e8\u547d\u4ee4\u8ba9\u5408\u5e76\u51b2\u7a81\u3001\u56de\u6eda\u3001\u5e76\u884c\u5f00\u53d1\u4e09\u6b65\u641e\u5b9a\uff0c\u6548\u7387\u7ffb\u4e09\u500d\uff0c\u590d\u5236\u5373\u7528\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[89,87,176],"topic":[],"class_list":["post-57307","post","type-post","status-publish","format-standard","hentry","category-server","tag-git","tag-87","tag-176"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/57307.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb139\u6b21\u3002\u9664 pull\/commit\/push \u5916\uff0cstash\u3001rebase\u3001worktree \u7b49 10 \u4e2a Git \u51b7\u95e8\u547d\u4ee4\u8ba9\u5408\u5e76\u51b2\u7a81\u3001\u56de\u6eda\u3001\u5e76\u884c\u5f00\u53d1\u4e09\u6b65\u641e\u5b9a\uff0c\u6548\u7387\u7ffb\u4e09\u500d\uff0c\u590d\u5236\u5373\u7528\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/57307.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-15T02:29:36+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57307.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/57307.html\",\"name\":\"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-15T02:29:36+00:00\",\"dateModified\":\"2025-08-15T02:29:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/57307.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/57307.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57307.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/57307.html","og_locale":"zh_CN","og_type":"article","og_title":"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb139\u6b21\u3002\u9664 pull\/commit\/push \u5916\uff0cstash\u3001rebase\u3001worktree \u7b49 10 \u4e2a Git \u51b7\u95e8\u547d\u4ee4\u8ba9\u5408\u5e76\u51b2\u7a81\u3001\u56de\u6eda\u3001\u5e76\u884c\u5f00\u53d1\u4e09\u6b65\u641e\u5b9a\uff0c\u6548\u7387\u7ffb\u4e09\u500d\uff0c\u590d\u5236\u5373\u7528\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/57307.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-15T02:29:36+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/57307.html","url":"https:\/\/www.wsisp.com\/helps\/57307.html","name":"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-15T02:29:36+00:00","dateModified":"2025-08-15T02:29:36+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/57307.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/57307.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/57307.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u9762\u8bd5\u5b98\u6700\u7231\u95ee\u7684 10 \u4e2a Git \u547d\u4ee4\uff0c\u7b54\u5b8c\u76f4\u63a5\u52a0\u5206"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=57307"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57307\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=57307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=57307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=57307"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=57307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}