{"id":90,"date":"2025-09-30T11:03:54","date_gmt":"2025-09-30T03:03:54","guid":{"rendered":"https:\/\/zcc609.online\/?p=90"},"modified":"2025-09-30T11:03:54","modified_gmt":"2025-09-30T03:03:54","slug":"6-git%e4%bd%bf%e7%94%a8%e8%a1%a5%e5%85%85","status":"publish","type":"post","link":"https:\/\/zcc609.online\/?p=90","title":{"rendered":"6.git\u4f7f\u7528\u8865\u5145"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"%E6%9C%AC%E5%9C%B0%E5%BC%80%E5%8F%91%E6%9A%82%E5%AD%98%E6%8F%90%E4%BA%A4\">\u672c\u5730\u5f00\u53d1\/\u6682\u5b58\/\u63d0\u4ea4<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u65b0\u529f\u80fd\u5f00\u53d1-feat\u3001\u7f3a\u9677\u4fee\u590d-fix<\/p>\n<\/blockquote>\n\n\n\n<p>\u9996\u5148\uff0c\u57fa\u4e8e\u6700\u65b0\u7684master\u5207\u6362\u4e00\u4e2a\u529f\u80fd\u5206\u652f-feat\/xxxx\u6216\u4fee\u590d\u5206\u652f-fix\/xxxx<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngit checkout -b feature\/xxxx master\n<\/pre><\/div>\n\n\n<p>\u672c\u5730\u5f00\u53d1\u5b8c\u6bd5\u540e\uff0c\u6dfb\u52a0\u672c\u5730\u4fee\u6539\u5230\u6682\u5b58\u533a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngit add .\n<\/pre><\/div>\n\n\n<p>\u63d0\u4ea4\u6682\u5b58\u533a\u6587\u4ef6\u5230\u672c\u5730\u4ed3\u5e93<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u5e38\u89c4\u4f7f\u7528\ngit commit -m &quot;\u6ce8\u91ca\u5185\u5bb9&quot;\n\/\/ \u4f8b\u5982\ngit commit -m &quot;feat: \u6dfb\u52a0xxxx\u529f\u80fd&quot;\n\n\/\/ \u4f7f\u7528git-cz\uff0c\u6839\u636ecli\u5bf9\u8bdd\u6846\u952e\u5165\u76f8\u5e94\u5185\u5bb9\ngit cz\n<\/pre><\/div>\n\n\n<p>\u5982\u679c\u6211\u5df2\u7ecf\u672c\u5730commit\u4e86\uff0c\u4f46\u662f\u53d1\u73b0\u8fd8\u9700\u8981\u7ee7\u7eed\u4fee\u6539\u6b64\u5206\u652f\uff0c\u4e3a\u4e86\u907f\u514d\u4e3b\u5e72\u5206\u652f\u51fa\u73b0\u8fc7\u591a\u5197\u4f59\u7684commit\uff0c\u539f\u5219\u4e0a\u6211\u4eec\u9700\u8981\u4fdd\u8bc1\u4e00\u4e2a\u5206\u652f\u53ea\u6709\u4e00\u6b21\u63d0\u4ea4\uff0c\u90a3\u4e48\u6211\u8be5\u5982\u4f55commit\uff1f<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u4f7f\u7528amend\u53c2\u6570\uff0c\u76f4\u63a5\u4fee\u6539\u4e0a\u6b21\u7684commit\n\n\/\/ \u5e38\u89c4\u4f7f\u7528\ngit commit --amend \n\n\/\/ \u4f7f\u7528git-cz\ngit cz --amend\n<\/pre><\/div>\n\n\n<p>\u63a8\u9001\u672c\u5730\u5206\u652f\u5230\u8fdc\u7aef\uff0c\u5982\u679c\u672c\u5730commit\u65f6\u4f7f\u7528\u8fc7amend\u53c2\u6570\uff0c\u5219push\u65f6\u9700\u8981\u52a0\u4e0af\u53c2\u6570\u5f3a\u63a8<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u672c\u5730commit\u65f6\uff0c\u6ca1\u6709amend\ngit push origin feat\/xxxx\n\n\/\/ \u672c\u5730commit\u65f6\uff0c\u6709\u8fc7\u4e00\u6b21\u6216\u591a\u6b21amend\ngit push origin feat\/xxxx -f\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"%E5%85%B3%E4%BA%8Emr%E5%89%8D%E5%88%86%E6%94%AF%E7%8A%B6%E6%80%81%E3%80%9001%E3%80%91%E7%9A%84%E8%A7%A3%E9%87%8A%EF%BC%8C%E4%BD%95%E6%97%B6%E8%AF%A5%E4%BD%BF%E7%94%A8restore%E3%80%81reset%E3%80%81rebase\">\u5173\u4e8eMR\u524d\u5206\u652f\u72b6\u6001\u30100|1\u3011\u7684\u89e3\u91ca\uff0c\u4f55\u65f6\u8be5\u4f7f\u7528restore\u3001reset\u3001rebase<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u4e3a\u4e86\u4fbf\u4e8e\u5feb\u901f\u5c06\u5206\u652f\u4ee3\u7801\u5408\u5e76\u5230\u4e3b\u5e72\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5408\u5e76\u51b2\u7a81\uff0c\u539f\u5219\u4e0a\u6211\u4eec\u9700\u8981\u5206\u652f\u76f8\u5bf9\u4e8e\u4e3b\u5e72\u7684\u72b6\u6001\u4e3a0|1\uff0c\u5373\u7b49\u5f85\u88ab\u5408\u5e76\u7684\u5206\u652f\u4e0d\u80fd\u843d\u540emaster\u5206\u652f\uff0c\u5e76\u4e14\u6700\u591a\u53ea\u80fd\u9886\u5148master\u4e00\u6b21commit\uff1b<br>\u9519\u8bef\u793a\u4f8b\u72b6\u6001\uff1a0|2\u30010|3\u30010|5\u7b49\uff0c21\u30014|1\u30016|1\u7b49<\/p>\n<\/blockquote>\n\n\n\n<p><strong>\u6211\u5728\u672c\u5730\u5f00\u53d1\u65f6\uff0c\u591a\u6b21commit\u65f6\u6ca1\u6709amend\uff0c\u600e\u4e48\u529e\uff1f<\/strong><\/p>\n\n\n\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u6bd4\u8f83\u5feb\u6377\u7684\u529e\u6cd5\uff0c\u76f4\u63a5rebase\ngit rebase -i\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u4e5f\u53ef\u4ee5\u9009\u62e9\u56de\u6eda\u91cd\u65b0\u63d0\u4ea4\n\/\/ \u9996\u5148\u56de\u6eda\u5230master\u5206\u652f\ngit reset &#x5B;master \u6216 master\u7684commitId]\n\n\/\/ \u7136\u540e\u91cd\u65b0add\ngit add .\n\/\/ \u91cd\u65b0commit\ngit commit -m &quot;\u91cd\u65b0\u6ce8\u91ca&quot;\n\/\/ \u6216\ngit cz\n\/\/ push\uff0c\u5982\u679c\u4e4b\u524d\u5df2\u7ecfpush\u8fc7\uff0c\u5219\u9700\u8981\u52a0\u4e0af\u5f3a\u63a8\ngit push origin feat\/xxxx &#x5B;-f]\n<\/pre><\/div>\n\n\n<p><strong>\u6211\u5df2\u7ecf\u63a8\u9001\u4e86\u5206\u652f\uff0c\u4f46\u662fMR\u524d\uff0c\u53d1\u73b0\u5df2\u7ecf\u843d\u540e\u4e8emaster\uff0c\u600e\u4e48\u529e\uff1f<\/strong><\/p>\n\n\n\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u9996\u5148\u672c\u5730\u5207\u6362\u5230master\u5206\u652f\u5e76\u66f4\u65b0\u5230\u6700\u65b0\ngit checkout master\ngit pull origin master\n\n\/\/ \u5207\u6362\u56de\u529f\u80fd\u5206\u652f\uff0c\u5408\u5e76\u672c\u5730master\u5206\u652f\u5230\u529f\u80fd\u5206\u652f\ngit checkout feat\/xxxx\ngit rebase master\n\n\/\/ \u5982\u679crebase\u8fc7\u7a0b\u9047\u5230\u51b2\u7a81\uff0c\u5206\u652f\u540e\u9762\u4f1a\u6807\u8bb0rebase\uff0c\u5904\u7406\u5b8c\u51b2\u7a81\u540e\uff0c\u5206\u652f\u540e\u9762rebase\u4f1a\u6d88\u5931\n\/\/ \u5904\u7406\u51b2\u7a81\u540e\u9700\u8981add\uff0c\u5e76\u7ee7\u7eedrebase\uff0c\u76f4\u5230\u6240\u6709\u51b2\u7a81\u6d88\u5931\ngit add .\ngit rebase --continue\n\n\/\/ \u63a8\u9001\u8be5\u529f\u80fd\u5206\u652f\uff0c\u7531\u4e8e\u6211\u4eec\u5728\u672c\u5730\u5408\u5e76\u4e86\u672a\u6765\u7684commit\uff0c\u6240\u4ee5\u9700\u8981\u5f3a\u63a8\ngit push origin feat\/xxxx -f\n<\/pre><\/div>\n\n\n<p><strong>\u6211\u6b64\u523b\u5df2\u7ecf\u5934\u76ae\u53d1\u9ebb\uff0c\u611f\u89c9\u81ea\u5df1\u7684\u4e1c\u897f\u8d8a\u6539\u8d8a\u4e71\uff0c\u60f3\u91cd\u7f6e\u672c\u6b21\u66f4\u6539\u5230\u6700\u521d\u72b6\u6001\uff0c\u600e\u4e48\u529e\uff1f<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ \u91cd\u7f6e\u672c\u6b21\u4fee\u6539\u5230\u521d\u59cb\u72b6\u6001\uff0c\u6ce8\u610f\u53ea\u662f\u6e05\u9664\u672c\u5730\u7684add\uff0c\u4e0d\u4f1a\u5f71\u54cdcommit\ngit restore .\n\/\/ \u6216\ngit restore fileName\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u672c\u5730\u5f00\u53d1\/\u6682\u5b58\/\u63d0\u4ea4 \u65b0\u529f\u80fd\u5f00\u53d1-feat\u3001\u7f3a\u9677\u4fee\u590d-fix \u9996\u5148\uff0c\u57fa\u4e8e\u6700\u65b0\u7684master\u5207\u6362\u4e00\u4e2a\u529f\u80fd\u5206\u652f-f &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/zcc609.online\/?p=90\" class=\"more-link\">Read more<span class=\"screen-reader-text\"> &#8220;6.git\u4f7f\u7528\u8865\u5145&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":1,"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":91,"href":"https:\/\/zcc609.online\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions\/91"}],"wp:attachment":[{"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zcc609.online\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}