{"id":106645,"date":"2026-09-17T21:32:40","date_gmt":"2026-09-17T13:32:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/106645.html"},"modified":"2026-09-17T21:32:40","modified_gmt":"2026-09-17T13:32:40","slug":"%e7%ac%ac4%e7%ab%a0%ef%bc%9agit%e5%88%86%e6%94%af%e4%b8%8e%e6%a0%87%e7%ad%be","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/106645.html","title":{"rendered":"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e"},"content":{"rendered":"<h2>\u7b2c4\u7ae0&#xff1a;Git\u5206\u652f\u4e0e\u6807\u7b7e<\/h2>\n<p>\u672c\u7ae0\u76ee\u6807<\/p>\n<li>\u7406\u89e3\u5206\u652f\u7684\u672c\u8d28\u4e0e HEAD \u7684\u5173\u7cfb<\/li>\n<li>\u638c\u63e1\u5206\u652f\u7684\u521b\u5efa\u3001\u5207\u6362\u3001\u91cd\u547d\u540d\u3001\u5220\u9664<\/li>\n<li>\u638c\u63e1\u5408\u5e76&#xff08;merge&#xff09;\u4e0e\u51b2\u7a81\u89e3\u51b3\u5b8c\u6574\u6d41\u7a0b<\/li>\n<li>\u7406\u89e3\u5e76\u4f1a\u4f7f\u7528\u53d8\u57fa&#xff08;rebase&#xff09;<\/li>\n<li>\u5b66\u4f1a\u7528\u6807\u7b7e&#xff08;tag&#xff09;\u6807\u8bb0\u7248\u672c<\/li>\n<li>\u4e86\u89e3\u5e38\u89c1\u7684\u5206\u652f\u7ba1\u7406\u6a21\u578b<\/li>\n<h3>1. \u4ec0\u4e48\u662f\u5206\u652f<\/h3>\n<p>\u5206\u652f&#xff08;Branch&#xff09; \u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u6761\u72ec\u7acb\u7684\u5f00\u53d1\u65f6\u95f4\u7ebf\u3002\u4f60\u53ef\u4ee5\u5728\u5206\u652f A \u4e0a\u5f00\u53d1\u65b0\u529f\u80fd&#xff0c;\u540c\u65f6\u4fdd\u6301\u4e3b\u5206\u652f B \u7684\u7a33\u5b9a&#xff0c;\u6700\u540e\u518d\u628a\u4e24\u6761\u7ebf\u5408\u5e76\u8d77\u6765\u3002<\/p>\n<p>Git \u7684\u5206\u652f\u4e0e\u5176\u4ed6\u5de5\u5177\u4e0d\u540c&#xff0c;\u5b83\u672c\u8d28\u4e0a\u53ea\u662f\u4e00\u4e2a\u6307\u5411\u63d0\u4ea4\u7684\u6307\u9488&#xff08;\u5b58\u4e00\u4e2a 40 \u4f4d\u7684\u54c8\u5e0c\u503c&#xff0c;\u53ea\u5360\u51e0\u5341\u4e2a\u5b57\u8282&#xff09;&#xff0c;\u6240\u4ee5\u521b\u5efa\u548c\u5207\u6362\u5206\u652f\u662f&#034;\u77ac\u95f4&#034;\u5b8c\u6210\u7684\u3002<\/p>\n<p>        main<br \/>\n         \u2193<br \/>\nA \u2500\u2500\u2500 B \u2500\u2500\u2500 C<br \/>\n             \\\\<br \/>\n              D \u2500\u2500\u2500 E   \u2190 dev \u5206\u652f<br \/>\n                   \u2191<br \/>\n                  dev<\/p>\n<ul>\n<li>main \u6307\u9488\u6307\u5411\u63d0\u4ea4 C<\/li>\n<li>dev \u6307\u9488\u6307\u5411\u63d0\u4ea4 E<\/li>\n<li>HEAD \u6307\u5411&#034;\u4f60\u5f53\u524d\u6240\u5728\u7684\u5206\u652f&#034;&#xff08;\u4e0a\u56fe\u5982\u679c HEAD \u2192 main&#xff0c;\u8bf4\u660e\u4f60\u5728 main \u5206\u652f\u4e0a\u5de5\u4f5c&#xff09;<\/li>\n<\/ul>\n<h4>1.1 \u4e3b\u5206\u652f\u53eb\u4ec0\u4e48&#xff1f;<\/h4>\n<ul>\n<li>\u65e9\u671f Git \u9ed8\u8ba4\u4e3b\u5206\u652f\u53eb master<\/li>\n<li>2020 \u5e74\u8d77&#xff0c;GitHub \u65b0\u5efa\u4ed3\u5e93\u9ed8\u8ba4\u53eb main&#xff1b;Gitee \u7684\u9ed8\u8ba4\u5206\u652f\u901a\u5e38\u662f master&#xff08;\u53ef\u5728\u4ed3\u5e93\u8bbe\u7f6e\u4e2d\u4fee\u6539&#xff09;<\/li>\n<li>Git 2.28&#043; \u53ef\u7528 git config &#8211;global init.defaultBranch main \u8bbe\u7f6e\u672c\u5730\u9ed8\u8ba4\u5206\u652f\u540d&#xff08;\u89c1 [[\u7b2c1\u7ae0&#xff1a;Git\u5165\u95e8\u4e0e\u73af\u5883\u642d\u5efa]]&#xff09;<\/li>\n<\/ul>\n<h3>2. \u5206\u652f\u57fa\u672c\u64cd\u4f5c<\/h3>\n<h4>2.1 \u67e5\u770b\u5206\u652f<\/h4>\n<p><span class=\"token function\">git<\/span> branch              <span class=\"token comment\"># \u672c\u5730\u5206\u652f&#xff08;\u5f53\u524d\u5206\u652f\u524d\u6709 * \u53f7&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-v<\/span>           <span class=\"token comment\"># \u663e\u793a\u6bcf\u4e2a\u5206\u652f\u6700\u540e\u4e00\u6b21\u63d0\u4ea4<\/span><br \/>\n<span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-a<\/span>           <span class=\"token comment\"># \u672c\u5730 &#043; \u8fdc\u7a0b\u5206\u652f&#xff08;remote \u5f00\u5934\u7684\u662f\u8fdc\u7a0b\u5206\u652f&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-vv<\/span>          <span class=\"token comment\"># \u663e\u793a\u5206\u652f\u4e0e\u8fdc\u7a0b\u7684\u8ffd\u8e2a\u5173\u7cfb<\/span><br \/>\n<span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">&#8211;merged<\/span>     <span class=\"token comment\"># \u5df2\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5206\u652f&#xff08;\u53ef\u5b89\u5168\u5220\u9664&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> branch &#8211;no-merged  <span class=\"token comment\"># \u672a\u5408\u5e76\u7684\u5206\u652f<\/span><\/p>\n<h4>2.2 \u521b\u5efa\u5206\u652f<\/h4>\n<p><span class=\"token function\">git<\/span> branch dev                  <span class=\"token comment\"># \u57fa\u4e8e\u5f53\u524d\u63d0\u4ea4\u521b\u5efa dev \u5206\u652f&#xff08;\u4e0d\u5207\u6362&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> branch dev <span class=\"token operator\">&lt;<\/span>commit<span class=\"token operator\">&gt;<\/span>         <span class=\"token comment\"># \u57fa\u4e8e\u6307\u5b9a\u63d0\u4ea4\u521b\u5efa<\/span><br \/>\n<span class=\"token function\">git<\/span> switch <span class=\"token parameter variable\">-c<\/span> dev               <span class=\"token comment\"># \u521b\u5efa\u5e76\u7acb\u5373\u5207\u6362&#xff08;\u63a8\u8350&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> checkout <span class=\"token parameter variable\">-b<\/span> dev             <span class=\"token comment\"># \u540c\u4e0a&#xff08;\u65e7\u5199\u6cd5&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> branch dev origin\/dev       <span class=\"token comment\"># \u57fa\u4e8e\u8fdc\u7a0b\u5206\u652f\u521b\u5efa\u672c\u5730\u5206\u652f<\/span><\/p>\n<p>[!tip] switch vs checkout<br \/>\ngit switch \u662f Git 2.23 \u5f15\u5165\u7684\u4e13\u7528\u5207\u6362\u5206\u652f\u547d\u4ee4&#xff0c;\u8bed\u4e49\u66f4\u6e05\u6670&#xff1b;git checkout \u4e00\u4e2a\u547d\u4ee4\u8eab\u517c\u6570\u804c&#xff08;\u5207\u5206\u652f\u3001\u6062\u590d\u6587\u4ef6&#xff09;&#xff0c;\u5bb9\u6613\u6df7\u6dc6\u3002\u5efa\u8bae\u65b0\u64cd\u4f5c\u4e60\u60ef\u7528 switch \/ restore\u3002<\/p>\n<h4>2.3 \u5207\u6362\u5206\u652f<\/h4>\n<p><span class=\"token function\">git<\/span> switch dev         <span class=\"token comment\"># \u5207\u6362\u5230 dev \u5206\u652f<\/span><br \/>\n<span class=\"token function\">git<\/span> switch &#8211;           <span class=\"token comment\"># \u5207\u56de\u4e0a\u4e00\u4e2a\u5206\u652f<\/span><br \/>\n<span class=\"token function\">git<\/span> switch <span class=\"token parameter variable\">-c<\/span> dev      <span class=\"token comment\"># \u521b\u5efa\u5e76\u5207\u6362<\/span><br \/>\n<span class=\"token function\">git<\/span> checkout dev       <span class=\"token comment\"># \u65e7\u5199\u6cd5<\/span><\/p>\n<p>[!warning] \u5207\u6362\u5206\u652f\u524d<br \/>\n\u5de5\u4f5c\u533a\u6709\u672a\u63d0\u4ea4\u7684\u6539\u52a8\u65f6&#xff1a;<\/p>\n<ul>\n<li>\u5982\u679c\u6539\u52a8\u4e0e\u76ee\u6807\u5206\u652f\u4e0d\u51b2\u7a81&#xff0c;Git \u4f1a\u628a\u6539\u52a8\u5e26\u8fc7\u53bb&#xff08;\u5bb9\u6613\u61f5&#xff09;<\/li>\n<li>\u5982\u679c\u51b2\u7a81&#xff0c;Git \u62d2\u7edd\u5207\u6362\u5e76\u8981\u6c42\u4f60\u5148 commit \u6216 stash<br \/>\n\u5efa\u8bae&#xff1a;\u5207\u6362\u5206\u652f\u524d\u4fdd\u8bc1\u5de5\u4f5c\u533a\u5e72\u51c0&#xff08;git status \u65e0\u8f93\u51fa&#xff09;&#xff0c;\u6216\u5148 git stash\u3002<\/li>\n<\/ul>\n<h4>2.4 \u91cd\u547d\u540d\u4e0e\u5220\u9664\u5206\u652f<\/h4>\n<p><span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-m<\/span> newname        <span class=\"token comment\"># \u91cd\u547d\u540d\u5f53\u524d\u5206\u652f<\/span><br \/>\n<span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-m<\/span> old new        <span class=\"token comment\"># \u91cd\u547d\u540d\u6307\u5b9a\u5206\u652f<\/span><br \/>\n<span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-d<\/span> dev            <span class=\"token comment\"># \u5220\u9664\u5df2\u5408\u5e76\u7684\u5206\u652f&#xff08;\u5b89\u5168&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> branch <span class=\"token parameter variable\">-D<\/span> dev            <span class=\"token comment\"># \u5f3a\u5236\u5220\u9664\u672a\u5408\u5e76\u5206\u652f&#xff08;\u5371\u9669&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> push origin <span class=\"token parameter variable\">&#8211;delete<\/span> dev <span class=\"token comment\"># \u5220\u9664\u8fdc\u7a0b\u5206\u652f<\/span><\/p>\n<p>[!warning] \u5220\u5206\u652f\u540e\u6094\u4e86&#xff1f;<br \/>\n\u53ea\u8981\u5206\u652f\u4e0a\u7684\u63d0\u4ea4\u66fe\u7ecf\u5b58\u5728\u8fc7&#xff0c;\u53ef\u4ee5\u5148 git reflog \u627e\u5230\u5bf9\u5e94\u63d0\u4ea4&#xff0c;\u7136\u540e git branch \u540d\u5b57 &lt;commit&gt; \u590d\u6d3b\u3002<\/p>\n<h3>3. \u5408\u5e76\u5206\u652f&#xff1a;git merge<\/h3>\n<p>\u5408\u5e76 &#061; \u628a\u53e6\u4e00\u4e2a\u5206\u652f\u7684\u6539\u52a8\u5e76\u5165\u5f53\u524d\u5206\u652f\u3002\u6ce8\u610f\u65b9\u5411&#xff1a;\u5148\u5207\u5230&#034;\u63a5\u6536\u65b9&#034;\u5206\u652f&#xff0c;\u518d\u5408\u5e76&#034;\u63d0\u4f9b\u65b9&#034;\u3002<\/p>\n<p><span class=\"token comment\"># \u628a dev \u5408\u5e76\u5230 main&#xff1a;\u5148\u5207\u5230 main&#xff0c;\u518d\u5408\u5e76 dev<\/span><br \/>\n<span class=\"token function\">git<\/span> switch main<br \/>\n<span class=\"token function\">git<\/span> merge dev<\/p>\n<h4>3.1 \u5feb\u8fdb\u5408\u5e76&#xff08;Fast-forward&#xff09;<\/h4>\n<p>\u5982\u679c\u4ece\u5171\u540c\u7956\u5148\u5230\u76ee\u6807\u5206\u652f\u662f&#034;\u4e00\u6761\u76f4\u7ebf&#034;&#xff08;main \u6ca1\u6709\u65b0\u63d0\u4ea4&#xff09;&#xff0c;Git \u53ea\u9700\u628a\u6307\u9488\u5411\u524d\u79fb\u52a8&#xff0c;\u8fd9\u53eb\u5feb\u8fdb\u5408\u5e76\u3002<\/p>\n<p>\u5408\u5e76\u524d&#xff1a;<br \/>\nA \u2500\u2500\u2500 B (main)<br \/>\n       \\\\<br \/>\n        C \u2500\u2500\u2500 D (dev)<\/p>\n<p>git switch main<br \/>\ngit merge dev<\/p>\n<p>\u5408\u5e76\u540e&#xff1a;<br \/>\nA \u2500\u2500\u2500 B \u2500\u2500\u2500 C \u2500\u2500\u2500 D (main, dev)    \u2190 main \u6307\u9488\u76f4\u63a5\u524d\u79fb&#xff0c;\u65e0\u65b0\u63d0\u4ea4<\/p>\n<p>\u60f3\u7981\u6b62\u5feb\u8fdb\u3001\u5f3a\u5236\u4ea7\u751f\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff08;\u4fdd\u7559\u5206\u652f\u75d5\u8ff9&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> merge &#8211;no-ff dev<\/p>\n<p>\u5408\u5e76\u540e&#xff08;&#8211;no-ff&#xff09;&#xff1a;<br \/>\nA \u2500\u2500\u2500 B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 M (main)<br \/>\n       \\\\          \/<br \/>\n        C \u2500\u2500\u2500 D   (dev)<\/p>\n<h4>3.2 \u4e09\u65b9\u5408\u5e76&#xff08;3-way merge&#xff09;<\/h4>\n<p>\u5982\u679c\u4e24\u8fb9\u90fd\u6709\u65b0\u63d0\u4ea4&#xff0c;Git \u4f1a\u627e\u5230\u5171\u540c\u7956\u5148&#xff0c;\u628a\u4e24\u8fb9\u7684\u6539\u52a8\u5408\u5e76&#xff0c;\u5e76\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff1a;<\/p>\n<p>\u5408\u5e76\u524d&#xff1a;<br \/>\n        C \u2500\u2500\u2500 D (dev)<br \/>\n       \/<br \/>\nA \u2500\u2500\u2500 B<br \/>\n       \\\\<br \/>\n        E \u2500\u2500\u2500 F (main)<\/p>\n<p>\u5408\u5e76\u540e&#xff1a;<br \/>\n        C \u2500\u2500\u2500 D (dev)<br \/>\n       \/        \\\\<br \/>\nA \u2500\u2500\u2500 B          M (main)  \u2190 \u5408\u5e76\u63d0\u4ea4<br \/>\n       \\\\        \/<br \/>\n        E \u2500\u2500\u2500 F<\/p>\n<p><span class=\"token function\">git<\/span> merge dev              <span class=\"token comment\"># \u81ea\u52a8\u5408\u5e76&#xff0c;\u5f39\u51fa\u63d0\u4ea4\u4fe1\u606f\u7f16\u8f91\u5668<\/span><br \/>\n<span class=\"token function\">git<\/span> merge dev <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;\u5408\u5e76dev\u5206\u652f&#034;<\/span>  <span class=\"token comment\"># \u6307\u5b9a\u5408\u5e76\u63d0\u4ea4\u4fe1\u606f<\/span><br \/>\n<span class=\"token function\">git<\/span> merge <span class=\"token parameter variable\">&#8211;abort<\/span>          <span class=\"token comment\"># \u5408\u5e76\u51fa\u95ee\u9898&#xff1f;\u653e\u5f03\u672c\u6b21\u5408\u5e76&#xff0c;\u56de\u5230\u5408\u5e76\u524d\u72b6\u6001<\/span><\/p>\n<h4>3.3 \u51b2\u7a81\u53ca\u5176\u89e3\u51b3&#xff08;\u91cd\u70b9&#xff09;<\/h4>\n<p>\u5f53\u4e24\u4e2a\u5206\u652f\u4fee\u6539\u4e86\u540c\u4e00\u6587\u4ef6\u7684\u540c\u4e00\u4f4d\u7f6e&#xff0c;Git \u65e0\u6cd5\u81ea\u52a8\u51b3\u5b9a\u7528\u8c01&#xff0c;\u5c31\u4f1a\u4ea7\u751f\u51b2\u7a81&#xff1a;<\/p>\n<p>Auto-merging hello.c<br \/>\nCONFLICT (content): Merge conflict in hello.c<br \/>\nAutomatic merge failed; fix conflicts and then commit the result.<\/p>\n<p>\u6b64\u65f6\u6587\u4ef6\u5185\u5bb9\u53d8\u6210&#xff1a;<\/p>\n<p><span class=\"token operator\">&lt;&lt;<\/span><span class=\"token operator\">&lt;&lt;<\/span><span class=\"token operator\">&lt;&lt;<\/span><span class=\"token operator\">&lt;<\/span> HEAD<br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hello from main&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token operator\">&#061;&#061;<\/span><span class=\"token operator\">&#061;&#061;<\/span><span class=\"token operator\">&#061;&#061;<\/span><span class=\"token operator\">&#061;<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hello from dev&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token operator\">&gt;&gt;<\/span><span class=\"token operator\">&gt;&gt;<\/span><span class=\"token operator\">&gt;&gt;<\/span><span class=\"token operator\">&gt;<\/span> dev<\/p>\n<p>\u542b\u4e49&#xff1a;<\/p>\n<ul>\n<li>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD \u5230 &#061;&#061;&#061;&#061;&#061;&#061;&#061; \u4e4b\u95f4&#xff1a;\u5f53\u524d\u5206\u652f\u7684\u5185\u5bb9<\/li>\n<li>&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u5230 &gt;&gt;&gt;&gt;&gt;&gt;&gt; dev \u4e4b\u95f4&#xff1a;\u8981\u5408\u5165\u7684 dev \u5206\u652f\u7684\u5185\u5bb9<\/li>\n<\/ul>\n<p>\u89e3\u51b3\u6b65\u9aa4&#xff1a;<\/p>\n<p><span class=\"token comment\"># 1. \u67e5\u770b\u54ea\u4e9b\u6587\u4ef6\u51b2\u7a81<\/span><br \/>\n<span class=\"token function\">git<\/span> status<br \/>\n<span class=\"token comment\"># \u8f93\u51fa&#xff1a;both modified:   hello.c<\/span><\/p>\n<p><span class=\"token comment\"># 2. \u6253\u5f00\u6587\u4ef6&#xff0c;\u624b\u52a8\u7f16\u8f91\u6210\u6700\u7ec8\u60f3\u8981\u7684\u5185\u5bb9&#xff08;\u5220\u6389 &lt;&lt;&lt;&lt;&lt;&lt;&lt; &#061;&#061;&#061;&#061;&#061;&#061;&#061; &gt;&gt;&gt;&gt;&gt;&gt;&gt; \u8fd9\u4e9b\u6807\u8bb0\u884c&#xff09;<\/span><br \/>\n<span class=\"token comment\">#    \u4f8b\u5982\u6539\u6210&#xff1a;printf(&#034;hello from main and dev&#034;);<\/span><\/p>\n<p><span class=\"token comment\"># 3. \u6807\u8bb0\u4e3a\u5df2\u89e3\u51b3&#xff08;\u628a\u6587\u4ef6\u52a0\u5165\u6682\u5b58\u533a&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> hello.c<\/p>\n<p><span class=\"token comment\"># 4. \u5b8c\u6210\u5408\u5e76\u63d0\u4ea4<\/span><br \/>\n<span class=\"token function\">git<\/span> commit          <span class=\"token comment\"># \u76f4\u63a5\u63d0\u4ea4\u5373\u53ef&#xff08;\u4fe1\u606f\u5df2\u9884\u586b&#xff09;<\/span><\/p>\n<p><span class=\"token comment\"># \u5982\u679c\u4e2d\u9014\u60f3\u653e\u5f03\u5408\u5e76&#xff1a;<\/span><br \/>\n<span class=\"token function\">git<\/span> merge <span class=\"token parameter variable\">&#8211;abort<\/span><\/p>\n<p>[!tip] \u51cf\u5c11\u51b2\u7a81\u7684\u6280\u5de7<\/p>\n<ul>\n<li>\u52e4 pull&#xff1a;\u7ecf\u5e38\u540c\u6b65\u8fdc\u7a0b\u6539\u52a8&#xff0c;\u51b2\u7a81\u7a97\u53e3\u66f4\u5c0f<\/li>\n<li>\u5c0f\u6b65\u63d0\u4ea4&#xff1a;\u4e00\u6b21\u63d0\u4ea4\u53ea\u505a\u4e00\u4ef6\u4e8b<\/li>\n<li>\u5206\u5de5\u6e05\u6670&#xff1a;\u907f\u514d\u591a\u4eba\u957f\u671f\u540c\u65f6\u6539\u540c\u4e00\u4e2a\u6587\u4ef6<\/li>\n<li>\u51b2\u7a81\u5de5\u5177&#xff1a;\u547d\u4ee4\u884c\u624b\u6539\u96be\u53d7\u65f6&#xff0c;\u7528 git mergetool \u6216 TortoiseGit \u7684\u4e09\u65b9\u5408\u5e76\u5de5\u5177&#xff08;\u89c1 [[\u7b2c7\u7ae0&#xff1a;TortoiseGit\u529f\u80fd\u8be6\u89e3]]&#xff09;<\/li>\n<\/ul>\n<h3>4. \u53d8\u57fa&#xff1a;git rebase<\/h3>\n<p>rebase &#061; \u628a\u5f53\u524d\u5206\u652f\u7684\u63d0\u4ea4&#034;\u642c&#034;\u5230\u53e6\u4e00\u4e2a\u5206\u652f\u7684\u6700\u65b0\u63d0\u4ea4\u4e4b\u540e&#xff0c;\u5f62\u6210\u4e00\u6761\u5e72\u51c0\u7684\u76f4\u7ebf\u5386\u53f2\u3002<\/p>\n<p><span class=\"token function\">git<\/span> switch dev<br \/>\n<span class=\"token function\">git<\/span> rebase main<\/p>\n<p>\u53d8\u57fa\u524d&#xff1a;<br \/>\n        C \u2500\u2500\u2500 D (dev)<br \/>\n       \/<br \/>\nA \u2500\u2500\u2500 B \u2500\u2500\u2500 E \u2500\u2500\u2500 F (main)<\/p>\n<p>\u53d8\u57fa\u540e&#xff08;dev \u7684 C\u3001D \u88ab\u590d\u5236\u4e3a C&#039;\u3001D&#039; \u63a5\u5230 F \u540e\u9762&#xff09;&#xff1a;<br \/>\nA \u2500\u2500\u2500 B \u2500\u2500\u2500 E \u2500\u2500\u2500 F (main)<br \/>\n                   \\\\<br \/>\n                    C&#039; \u2500\u2500\u2500 D&#039; (dev)<\/p>\n<h4>4.1 merge \u4e0e rebase \u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u5bf9\u6bd4\u9879mergerebase<\/tr>\n<tbody>\n<tr>\n<td>\u5386\u53f2\u5f62\u72b6<\/td>\n<td>\u5206\u53c9\u7684&#xff08;\u4fdd\u7559\u771f\u5b9e\u8f68\u8ff9&#xff09;<\/td>\n<td>\u76f4\u7ebf\u7684&#xff08;\u88ab\u6574\u7406\u8fc7&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u6539\u5199\u63d0\u4ea4<\/td>\n<td>\u5426<\/td>\n<td>\u662f&#xff08;\u751f\u6210\u65b0\u54c8\u5e0c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u51b2\u7a81\u89e3\u51b3\u6b21\u6570<\/td>\n<td>\u4e00\u6b21<\/td>\n<td>\u53ef\u80fd\u6bcf\u4e2a\u63d0\u4ea4\u90fd\u8981\u89e3\u51b3<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528\u573a\u666f<\/td>\n<td>\u516c\u5171\u5206\u652f\u5408\u5e76<\/td>\n<td>\u79c1\u4eba\u5206\u652f\u540c\u6b65\u4e3b\u5206\u652f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>[!warning] rebase \u7684\u9ec4\u91d1\u6cd5\u5219<br \/>\n\u4e0d\u8981\u5bf9\u5df2\u7ecf\u63a8\u9001\u5230\u8fdc\u7a0b\u7684\u516c\u5171\u5206\u652f\u6267\u884c rebase&#xff01; \u56e0\u4e3a\u5b83\u6539\u5199\u4e86\u63d0\u4ea4\u5386\u53f2&#xff0c;\u4f1a\u8ba9\u5176\u4ed6\u4eba\u7684\u4ed3\u5e93\u4e0e\u4f60\u7684\u5bf9\u4e0d\u4e0a\u3002rebase \u81ea\u5df1\u7684\u79c1\u6709\u5206\u652f\u5219\u6ca1\u95ee\u9898\u3002<\/p>\n<h4>4.2 \u4ea4\u4e92\u5f0f\u53d8\u57fa&#xff08;\u6574\u7406\u63d0\u4ea4&#xff09;<\/h4>\n<p><span class=\"token function\">git<\/span> rebase <span class=\"token parameter variable\">-i<\/span> HEAD~3     <span class=\"token comment\"># \u7f16\u8f91\u6700\u8fd1 3 \u4e2a\u63d0\u4ea4<\/span><\/p>\n<p>\u7f16\u8f91\u5668\u4f1a\u5217\u51fa&#xff1a;<\/p>\n<p>pick f7f3f6d \u4fee\u590d\u4e86\u7b2c\u4e00\u4e2a\u95ee\u9898<br \/>\npick 310154e \u4fee\u590d\u4e86\u7b2c\u4e8c\u4e2a\u95ee\u9898<br \/>\npick a5f4a0d \u6539\u6b63\u4e86\u9519\u522b\u5b57<\/p>\n<p>\u628a pick \u6539\u6210\u5176\u4ed6\u6307\u4ee4&#xff08;\u60f3\u8c03\u6574\u63d0\u4ea4\u987a\u5e8f\u65f6&#xff0c;\u76f4\u63a5\u4e0a\u4e0b\u79fb\u52a8\u884c\u5373\u53ef&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u6307\u4ee4\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>pick<\/td>\n<td>\u4fdd\u7559\u8be5\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>reword<\/td>\n<td>\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>edit<\/td>\n<td>\u505c\u4e0b\u6765\u4fee\u6539\u8be5\u63d0\u4ea4\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td>squash<\/td>\n<td>\u5408\u5e76\u5230\u4e0a\u4e00\u4e2a\u63d0\u4ea4&#xff0c;\u5408\u5e76\u63d0\u4ea4\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>fixup<\/td>\n<td>\u5408\u5e76\u5230\u4e0a\u4e00\u4e2a\u63d0\u4ea4&#xff0c;\u4e22\u5f03\u672c\u6761\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>drop<\/td>\n<td>\u5220\u9664\u8be5\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>exec<\/td>\n<td>\u5728\u8be5\u4f4d\u7f6e\u6267\u884c\u4e00\u6761\u81ea\u5b9a\u4e49\u547d\u4ee4&#xff08;\u8fdb\u9636&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>[!example] \u5e38\u7528\u573a\u666f<br \/>\n\u628a\u6700\u8fd1 3 \u4e2a&#034;\u6539bug\u3001\u518d\u6539bug\u3001\u8fd8\u6539bug&#034;\u7684\u788e\u63d0\u4ea4\u538b\u6210\u4e00\u4e2a\u5e72\u51c0\u7684\u63d0\u4ea4&#xff1a;git rebase -i HEAD~3&#xff0c;\u540e\u4e24\u6761\u524d\u9762\u6539\u6210 squash \u6216 fixup\u3002<\/p>\n<h4>4.3 rebase \u9047\u5230\u51b2\u7a81<\/h4>\n<p><span class=\"token comment\"># \u89e3\u51b3\u6389\u51b2\u7a81\u6587\u4ef6\u540e&#xff1a;<\/span><br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> <span class=\"token operator\">&lt;<\/span>\u6587\u4ef6<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token function\">git<\/span> rebase <span class=\"token parameter variable\">&#8211;continue<\/span><\/p>\n<p><span class=\"token comment\"># \u60f3\u653e\u5f03\u53d8\u57fa&#xff0c;\u56de\u5230\u53d8\u57fa\u524d&#xff1a;<\/span><br \/>\n<span class=\"token function\">git<\/span> rebase <span class=\"token parameter variable\">&#8211;abort<\/span><\/p>\n<p><span class=\"token comment\"># \u8df3\u8fc7\u5f53\u524d\u8fd9\u4e2a\u63d0\u4ea4&#xff1a;<\/span><br \/>\n<span class=\"token function\">git<\/span> rebase <span class=\"token parameter variable\">&#8211;skip<\/span><\/p>\n<h4>4.4 \u7b49\u6548\u7684 pull &#8211;rebase<\/h4>\n<p>\u62c9\u53d6\u8fdc\u7a0b\u66f4\u65b0\u65f6&#xff0c;\u5982\u679c\u672c\u5730\u6709\u63d0\u4ea4&#xff0c;\u9ed8\u8ba4\u4f1a\u4ea7\u751f\u5408\u5e76\u63d0\u4ea4\u3002\u60f3\u7528\u53d8\u57fa\u65b9\u5f0f\u4fdd\u6301\u76f4\u7ebf&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> pull <span class=\"token parameter variable\">&#8211;rebase<\/span><br \/>\n<span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> pull.rebase <span class=\"token boolean\">true<\/span>   <span class=\"token comment\"># \u6c38\u4e45\u8bbe\u4e3a\u9ed8\u8ba4\u884c\u4e3a<\/span><\/p>\n<h3>5. \u6807\u7b7e&#xff1a;git tag<\/h3>\n<p>\u6807\u7b7e\u7528\u4e8e\u7ed9\u67d0\u4e2a\u63d0\u4ea4\u8d77\u4e00\u4e2a&#034;\u6c38\u4e45\u6027\u7684\u540d\u5b57&#034;&#xff0c;\u5178\u578b\u7528\u9014\u662f\u6807\u8bb0\u7248\u672c\u53f7&#xff08;v1.0\u3001v2.1.3&#xff09;\u3002\u5206\u652f\u4f1a\u79fb\u52a8&#xff0c;\u6807\u7b7e\u4e0d\u4f1a\u3002<\/p>\n<h4>5.1 \u521b\u5efa\u6807\u7b7e<\/h4>\n<p><span class=\"token function\">git<\/span> tag v1.0                        <span class=\"token comment\"># \u8f7b\u91cf\u6807\u7b7e&#xff08;\u53ea\u662f\u4e2a\u6307\u9488&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> tag <span class=\"token parameter variable\">-a<\/span> v1.0 <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;1.0 \u6b63\u5f0f\u7248\u53d1\u5e03&#034;<\/span>  <span class=\"token comment\"># \u9644\u6ce8\u6807\u7b7e&#xff08;\u542b\u4f5c\u8005\u3001\u65e5\u671f\u3001\u8bf4\u660e&#xff0c;\u63a8\u8350&#xff09;<\/span><br \/>\n<span class=\"token function\">git<\/span> tag <span class=\"token parameter variable\">-a<\/span> v1.0 9fceb02             <span class=\"token comment\"># \u7ed9\u5386\u53f2\u63d0\u4ea4\u8865\u6253\u6807\u7b7e<\/span><\/p>\n<h4>5.2 \u67e5\u770b\u4e0e\u68c0\u51fa<\/h4>\n<p><span class=\"token function\">git<\/span> tag                     <span class=\"token comment\"># \u5217\u51fa\u5168\u90e8\u6807\u7b7e<\/span><br \/>\n<span class=\"token function\">git<\/span> tag <span class=\"token parameter variable\">-l<\/span> <span class=\"token string\">&#034;v1.*&#034;<\/span>           <span class=\"token comment\"># \u6309\u6a21\u5f0f\u8fc7\u6ee4<\/span><br \/>\n<span class=\"token function\">git<\/span> show v1.0               <span class=\"token comment\"># \u67e5\u770b\u6807\u7b7e\u8be6\u60c5<\/span><br \/>\n<span class=\"token function\">git<\/span> switch <span class=\"token parameter variable\">-c<\/span> hotfix v1.0   <span class=\"token comment\"># \u57fa\u4e8e\u6807\u7b7e\u521b\u5efa\u5206\u652f<\/span><\/p>\n<h4>5.3 \u63a8\u9001\u4e0e\u5220\u9664\u6807\u7b7e<\/h4>\n<p>\u6807\u7b7e\u4e0d\u4f1a\u968f git push \u81ea\u52a8\u4e0a\u4f20&#xff0c;\u8981\u5355\u72ec\u63a8&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> push origin v1.0        <span class=\"token comment\"># \u63a8\u9001\u5355\u4e2a\u6807\u7b7e<\/span><br \/>\n<span class=\"token function\">git<\/span> push origin <span class=\"token parameter variable\">&#8211;tags<\/span>      <span class=\"token comment\"># \u63a8\u9001\u6240\u6709\u672c\u5730\u6807\u7b7e<\/span><br \/>\n<span class=\"token function\">git<\/span> tag <span class=\"token parameter variable\">-d<\/span> v1.0             <span class=\"token comment\"># \u5220\u9664\u672c\u5730\u6807\u7b7e<\/span><br \/>\n<span class=\"token function\">git<\/span> push origin <span class=\"token parameter variable\">&#8211;delete<\/span> v1.0   <span class=\"token comment\"># \u5220\u9664\u8fdc\u7a0b\u6807\u7b7e<\/span><\/p>\n<h3>6. \u5e38\u89c1\u5206\u652f\u6a21\u578b<\/h3>\n<h4>6.1 Git Flow&#xff08;\u7ecf\u5178\u6a21\u578b&#xff09;<\/h4>\n<p>main      \u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500   \u53ea\u653e\u6b63\u5f0f\u53d1\u5e03<br \/>\n              \\\\            \/        \/<br \/>\nrelease        \u25cf\u2500\u2500\u25cf\u2500\u2500\u25cf\u2500\u2500\u2500\u25cf        \/         \u53d1\u5e03\u51c6\u5907<br \/>\n                \\\\                \/<br \/>\ndevelop  \u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500   \u65e5\u5e38\u5f00\u53d1\u4e3b\u5e72<br \/>\n             \\\\      \/      \\\\      \/<br \/>\nfeature       \u25cf\u2500\u2500\u2500\u25cf        \u25cf\u2500\u2500\u2500\u2500\u25cf           \u529f\u80fd\u5206\u652f<\/p>\n<table>\n<tr>\u5206\u652f\u7528\u9014<\/tr>\n<tbody>\n<tr>\n<td>main<\/td>\n<td>\u53ea\u5305\u542b\u5df2\u53d1\u5e03\u7248\u672c&#xff0c;\u6bcf\u4e2a\u63d0\u4ea4\u6253\u6807\u7b7e<\/td>\n<\/tr>\n<tr>\n<td>develop<\/td>\n<td>\u5f00\u53d1\u4e3b\u5e72&#xff0c;\u529f\u80fd\u90fd\u5148\u5408\u5230\u8fd9\u91cc<\/td>\n<\/tr>\n<tr>\n<td>feature\/*<\/td>\n<td>\u6bcf\u4e2a\u65b0\u529f\u80fd\u4e00\u4e2a\u5206\u652f&#xff0c;\u5b8c\u6210\u540e\u5408\u56de develop<\/td>\n<\/tr>\n<tr>\n<td>release\/*<\/td>\n<td>\u53d1\u5e03\u51c6\u5907&#xff08;\u4fee bug\u3001\u6539\u7248\u672c\u53f7&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>hotfix\/*<\/td>\n<td>\u7ebf\u4e0a\u7d27\u6025\u4fee\u590d&#xff0c;\u4ece main \u62c9\u51fa&#xff0c;\u4fee\u5b8c\u5408\u56de main &#043; develop<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9002\u5408\u7248\u672c\u53d1\u5e03\u8282\u594f\u660e\u786e\u7684\u4e2d\u5927\u578b\u9879\u76ee&#xff0c;\u6d41\u7a0b\u504f\u91cd\u3002<\/p>\n<h4>6.2 GitHub Flow&#xff08;\u8f7b\u91cf\u6a21\u578b&#xff09;<\/h4>\n<p>main \u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500<br \/>\n         \\\\    \\\\       \/    \/<br \/>\nfeature   \u25cf\u2500\u2500\u2500\u2500\u25cf\u2500\u2500\u2500\u2500\u2500\u25cf    \/       \u4ece main \u62c9\u529f\u80fd\u5206\u652f<br \/>\n                \\\\        \/<br \/>\n                 \u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u25cf          \u5408\u5e76\u56de main \u540e\u53ef\u7acb\u5373\u90e8\u7f72<\/p>\n<ul>\n<li>\u53ea\u6709 main \u4e00\u6761\u957f\u671f\u5206\u652f<\/li>\n<li>\u4efb\u4f55\u6539\u52a8\u90fd\u4ece main \u62c9\u5206\u652f \u2192 \u63d0\u4ea4 \u2192 \u53d1\u8d77 Pull Request \u2192 \u8bc4\u5ba1 \u2192 \u5408\u5e76<\/li>\n<li>\u5408\u5e76\u5373\u53ef\u90e8\u7f72&#xff0c;\u9002\u5408\u6301\u7eed\u4ea4\u4ed8\u7684 Web \u9879\u76ee<\/li>\n<\/ul>\n<h4>6.3 \u9002\u5408\u4e2a\u4eba \/ \u5c0f\u56e2\u961f\u7684\u505a\u6cd5<\/h4>\n<ul>\n<li>\u5355\u4eba\u9879\u76ee&#xff1a;\u76f4\u63a5\u4e00\u4e2a main \u5206\u652f &#043; \u5b9a\u671f\u6253\u6807\u7b7e\u5373\u53ef<\/li>\n<li>2-5 \u4eba&#xff1a;main &#043; feature \u5206\u652f &#043; PR \u8bc4\u5ba1<\/li>\n<li>\u517b\u6210\u4e60\u60ef&#xff1a;\u4efb\u4f55\u65b0\u529f\u80fd\u3001\u4fee\u590d\u90fd\u5f00\u65b0\u5206\u652f&#xff0c;\u5f00\u53d1\u5b8c\u5408\u5e76\u56de main<\/li>\n<\/ul>\n<h3>7. \u672c\u7ae0\u5c0f\u7ed3<\/h3>\n<ul>\n<li>\u5206\u652f\u672c\u8d28\u662f\u6307\u5411\u63d0\u4ea4\u7684\u53ef\u79fb\u52a8\u6307\u9488&#xff0c;\u521b\u5efa\/\u5207\u6362\u6781\u5feb<\/li>\n<li>\u5408\u5e76\u65b9\u5411&#xff1a;\u5148\u5207\u5230\u63a5\u6536\u65b9&#xff0c;\u518d git merge \u63d0\u4f9b\u65b9<\/li>\n<li>\u51b2\u7a81&#061;\u540c\u4e00\u4f4d\u7f6e\u88ab\u4e24\u8fb9\u4fee\u6539&#xff1b;\u89e3\u51b3&#061;\u624b\u52a8\u7f16\u8f91 \u2192 git add \u2192 git commit<\/li>\n<li>rebase \u8ba9\u5386\u53f2\u53d8\u76f4\u7ebf&#xff0c;\u4f46\u522b\u52a8\u516c\u5171\u5206\u652f<\/li>\n<li>\u6807\u7b7e\u7528\u4e8e\u6807\u8bb0\u7248\u672c&#xff1b;git push &#8211;tags \u624d\u4f1a\u540c\u6b65\u5230\u8fdc\u7a0b<\/li>\n<li>\u5c0f\u56e2\u961f\u63a8\u8350 GitHub Flow&#xff1a;main &#043; \u529f\u80fd\u5206\u652f &#043; \u5408\u5e76<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c4\u7ae0&#xff1a;Git\u5206\u652f\u4e0e\u6807\u7b7e\u672c\u7ae0\u76ee\u6807<br \/>\n\u7406\u89e3\u5206\u652f\u7684\u672c\u8d28\u4e0e HEAD \u7684\u5173\u7cfb\u638c\u63e1\u5206\u652f\u7684\u521b\u5efa\u3001\u5207\u6362\u3001\u91cd\u547d\u540d\u3001\u5220\u9664\u638c\u63e1\u5408\u5e76&#xff08;merge&#xff09;\u4e0e\u51b2\u7a81\u89e3\u51b3\u5b8c\u6574\u6d41\u7a0b\u7406\u89e3\u5e76\u4f1a\u4f7f\u7528\u53d8\u57fa&#xff08;rebase&#xff09;\u5b66\u4f1a\u7528\u6807\u7b7e&#xff08;tag&#xff09;\u6807\u8bb0\u7248\u672c\u4e86\u89e3\u5e38\u89c1\u7684\u5206\u652f\u7ba1\u7406\u6a21\u578b1. \u4ec0\u4e48\u662f\u5206\u652f<br \/>\n\u5206\u652f&#xff08;Branch&#xff09; \u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u6761\u72ec\u7acb\u7684\u5f00\u53d1\u65f6\u95f4\u7ebf\u3002\u4f60\u53ef\u4ee5\u5728\u5206\u652f A \u4e0a\u5f00\u53d1\u65b0\u529f\u80fd&#xff0c;\u540c\u65f6\u4fdd\u6301\u4e3b\u5206<\/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],"topic":[],"class_list":["post-106645","post","type-post","status-publish","format-standard","hentry","category-server","tag-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e - \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\/106645.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7b2c4\u7ae0&#xff1a;Git\u5206\u652f\u4e0e\u6807\u7b7e\u672c\u7ae0\u76ee\u6807 \u7406\u89e3\u5206\u652f\u7684\u672c\u8d28\u4e0e HEAD \u7684\u5173\u7cfb\u638c\u63e1\u5206\u652f\u7684\u521b\u5efa\u3001\u5207\u6362\u3001\u91cd\u547d\u540d\u3001\u5220\u9664\u638c\u63e1\u5408\u5e76&#xff08;merge&#xff09;\u4e0e\u51b2\u7a81\u89e3\u51b3\u5b8c\u6574\u6d41\u7a0b\u7406\u89e3\u5e76\u4f1a\u4f7f\u7528\u53d8\u57fa&#xff08;rebase&#xff09;\u5b66\u4f1a\u7528\u6807\u7b7e&#xff08;tag&#xff09;\u6807\u8bb0\u7248\u672c\u4e86\u89e3\u5e38\u89c1\u7684\u5206\u652f\u7ba1\u7406\u6a21\u578b1. \u4ec0\u4e48\u662f\u5206\u652f \u5206\u652f&#xff08;Branch&#xff09; \u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u6761\u72ec\u7acb\u7684\u5f00\u53d1\u65f6\u95f4\u7ebf\u3002\u4f60\u53ef\u4ee5\u5728\u5206\u652f A \u4e0a\u5f00\u53d1\u65b0\u529f\u80fd&#xff0c;\u540c\u65f6\u4fdd\u6301\u4e3b\u5206\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/106645.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-17T13:32:40+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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106645.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/106645.html\",\"name\":\"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-17T13:32:40+00:00\",\"dateModified\":\"2026-09-17T13:32:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/106645.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/106645.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106645.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e\"}]},{\"@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":"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e - \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\/106645.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7b2c4\u7ae0&#xff1a;Git\u5206\u652f\u4e0e\u6807\u7b7e\u672c\u7ae0\u76ee\u6807 \u7406\u89e3\u5206\u652f\u7684\u672c\u8d28\u4e0e HEAD \u7684\u5173\u7cfb\u638c\u63e1\u5206\u652f\u7684\u521b\u5efa\u3001\u5207\u6362\u3001\u91cd\u547d\u540d\u3001\u5220\u9664\u638c\u63e1\u5408\u5e76&#xff08;merge&#xff09;\u4e0e\u51b2\u7a81\u89e3\u51b3\u5b8c\u6574\u6d41\u7a0b\u7406\u89e3\u5e76\u4f1a\u4f7f\u7528\u53d8\u57fa&#xff08;rebase&#xff09;\u5b66\u4f1a\u7528\u6807\u7b7e&#xff08;tag&#xff09;\u6807\u8bb0\u7248\u672c\u4e86\u89e3\u5e38\u89c1\u7684\u5206\u652f\u7ba1\u7406\u6a21\u578b1. \u4ec0\u4e48\u662f\u5206\u652f \u5206\u652f&#xff08;Branch&#xff09; \u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u6761\u72ec\u7acb\u7684\u5f00\u53d1\u65f6\u95f4\u7ebf\u3002\u4f60\u53ef\u4ee5\u5728\u5206\u652f A \u4e0a\u5f00\u53d1\u65b0\u529f\u80fd&#xff0c;\u540c\u65f6\u4fdd\u6301\u4e3b\u5206","og_url":"https:\/\/www.wsisp.com\/helps\/106645.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-17T13:32:40+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/106645.html","url":"https:\/\/www.wsisp.com\/helps\/106645.html","name":"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-17T13:32:40+00:00","dateModified":"2026-09-17T13:32:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/106645.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/106645.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/106645.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b2c4\u7ae0\uff1aGit\u5206\u652f\u4e0e\u6807\u7b7e"}]},{"@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\/106645","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=106645"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106645\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=106645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=106645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=106645"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=106645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}