{"id":19310,"date":"2024-11-19T09:35:24","date_gmt":"2024-11-19T01:35:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19310\/"},"modified":"2024-11-19T09:35:24","modified_gmt":"2024-11-19T01:35:24","slug":"git%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9%e5%88%86%e6%94%af%e5%90%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19310\/","title":{"rendered":"Git\u5982\u4f55\u4fee\u6539\u5206\u652f\u540d"},"content":{"rendered":"<p>git \u4f7f\u7528\u5206\u652f\u662f\u4e00\u79cd\u975e\u5e38\u91cd\u8981\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002\u800c\u6709\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u4fee\u6539\u5206\u652f\u540d\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u5206\u652f\u540d\u8fc7\u957f\u3001\u62fc\u5199\u9519\u8bef\u3001\u547d\u540d\u4e0d\u89c4\u8303\u7b49\u7b49\u539f\u56e0\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u5c31\u6765\u4ecb\u7ecd\u4e00\u4e0b git \u5982\u4f55\u4fee\u6539\u5206\u652f\u540d\u3002<\/p>\n<ol>\n<li>\u67e5\u770b\u5206\u652f<\/li>\n<\/ol>\n<p>\u5728\u4fee\u6539\u5206\u652f\u540d\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u77e5\u9053\u5f53\u524d\u6240\u6709\u7684\u5206\u652f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u672c\u5730\u7684\u6240\u6709\u5206\u652f\uff1a<\/p>\n<pre>$ git branch<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u91cc\u4f1a\u7f57\u5217\u51fa\u6240\u6709\u7684\u672c\u5730\u5206\u652f\u7684\u5217\u8868\uff0c\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u6240\u5728\u7684\u5206\u652f\u524d\u9762\u4f1a\u6709\u4e00\u4e2a\u661f\u53f7\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>  master\n* dev\n  feature-1\n  feature-2<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u4fee\u6539\u672c\u5730\u5206\u652f\u540d<\/li>\n<\/ol>\n<p>\u5728 Git \u4e2d\uff0c\u4fee\u6539\u5206\u652f\u540d\u4e3b\u8981\u6709\u4e09\u79cd\u65b9\u5f0f\uff0c\u5206\u522b\u662f\uff1a<\/p>\n<ul>\n<li>\u91cd\u547d\u540d\u5206\u652f<\/li>\n<li>\u5220\u9664\u5206\u652f\u518d\u521b\u5efa\u65b0\u7684\u5206\u652f<\/li>\n<li>\u521b\u5efa\u65b0\u7684\u5206\u652f\u518d\u5220\u9664\u65e7\u7684\u5206\u652f<\/li>\n<\/ul>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c31\u6765\u4e00\u4e00\u4ecb\u7ecd\u8fd9\u4e09\u79cd\u65b9\u5f0f\u3002<\/p>\n<p>2.1 \u91cd\u547d\u540d\u5206\u652f<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u91cd\u547d\u540d\u5206\u652f\uff1a<\/p>\n<pre>$ git branch -m &lt;old-branch-name&gt; &lt;new-branch-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0c\u201c-m\u201d \u8868\u793a \u201cmove\u201d\uff0c\u5373\u79fb\u52a8\/\u91cd\u547d\u540d\u3002\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8bb0\u5f97\u5207\u6362\u5230\u5176\u4ed6\u5206\u652f\u8fdb\u884c\u64cd\u4f5c\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n<p>2.2 \u5220\u9664\u5206\u652f\u518d\u521b\u5efa\u65b0\u7684\u5206\u652f<\/p>\n<p>\u8be5\u65b9\u6cd5\u4e3b\u8981\u5206\u4e24\u6b65\u8fdb\u884c\uff1a<\/p>\n<ul>\n<li>\u5220\u9664\u65e7\u7684\u5206\u652f<\/li>\n<li>\u521b\u5efa\u65b0\u7684\u5206\u652f<\/li>\n<\/ul>\n<p>\u6b65\u9aa4\u4e00\uff0c\u5220\u9664\u65e7\u7684\u5206\u652f\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git branch -d &lt;old-branch-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8be5\u547d\u4ee4\u4f1a\u5c06\u6307\u5b9a\u7684\u65e7\u5206\u652f\u5220\u9664\u3002<\/p>\n<p>\u6b65\u9aa4\u4e8c\uff0c\u521b\u5efa\u65b0\u7684\u5206\u652f\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$ git branch &lt;new-branch-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6837\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\uff0c\u5e76\u4e14\u548c\u5f53\u524d\u6240\u5728\u7684\u5206\u652f\u62e5\u6709\u76f8\u540c\u7684\u7236\u8282\u70b9\u3002<\/p>\n<p>2.3 \u521b\u5efa\u65b0\u7684\u5206\u652f\u518d\u5220\u9664\u65e7\u7684\u5206\u652f<\/p>\n<p>\u8be5\u65b9\u6cd5\u4e5f\u662f\u5206\u4e24\u6b65\u8fdb\u884c\uff1a<\/p>\n<ul>\n<li>\u521b\u5efa\u65b0\u7684\u5206\u652f<\/li>\n<li>\u5220\u9664\u65e7\u7684\u5206\u652f<\/li>\n<\/ul>\n<p>\u6b65\u9aa4\u4e00\uff0c\u521b\u5efa\u65b0\u7684\u5206\u652f\uff1a<\/p>\n<pre>$ git branch &lt;new-branch-name&gt; \n  <\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6837\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u5206\u652f\uff0c\u65b0\u5206\u652f\u7684\u4ee3\u7801\u548c\u65e7\u5206\u652f\u7684\u4ee3\u7801\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n<p>\u6b65\u9aa4\u4e8c\uff0c\u5220\u9664\u65e7\u7684\u5206\u652f\uff1a<\/p>\n<pre>$ git branch -d &lt;old-branch-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6837\u5c31\u4f1a\u5c06\u65e7\u7684\u5206\u652f\u5220\u9664\u3002<\/p>\n<ol>\n<li>\u63a8\u9001\u4fee\u6539\u540e\u7684\u5206\u652f\u540d<\/li>\n<\/ol>\n<p>\u4fee\u6539\u672c\u5730\u5206\u652f\u540d\u540e\uff0c\u9700\u8981\u8ba9\u8fdc\u7a0b\u5206\u652f\u540c\u6b65\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u63a8\u9001\u4fee\u6539\u540e\u7684\u5206\u652f\u540d\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<pre>$ git push origin :&lt;old-branch-name&gt;\n$ git push origin &lt;new-branch-name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e0a\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u201c:\u201d \u8868\u793a\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u5220\u9664\u6307\u5b9a\u7684\u5206\u652f\uff0c\u7136\u540e\u4f7f\u7528\u7b2c\u4e8c\u6761\u547d\u4ee4\u5c06\u65b0\u7684\u5206\u652f\u63a8\u9001\u5230\u4ed3\u5e93\u4e2d\u3002<\/p>\n<ol>\n<li>\u603b\u7ed3<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662f Git \u4fee\u6539\u5206\u652f\u540d\u7684\u4e09\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u9009\u62e9\u3002\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u64cd\u4f5c Git \u7684\u65f6\u5019\u4e00\u5b9a\u8981\u5c0f\u5fc3\u8c28\u614e\uff0c\u786e\u4fdd\u4e0d\u4f1a\u8bef\u64cd\u4f5c\uff0c\u5f15\u53d1\u4e0d\u5fc5\u8981\u7684\u9ebb\u70e6\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fGit\u5982\u4f55\u4fee\u6539\u5206\u652f\u540d\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>git \u4f7f\u7528\u5206\u652f\u662f\u4e00\u79cd\u975e\u5e38\u91cd\u8981\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002\u800c\u6709\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u4fee\u6539\u5206\u652f\u540d\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u5206\u652f\u540d\u8fc7\u957f\u3001\u62fc\u5199\u9519\u8bef\u3001\u547d\u540d\u4e0d\u89c4\u8303\u7b49\u7b49\u539f\u56e0\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u5c31\u6765\u4ecb\u7ecd\u4e00\u4e0b git \u5982\u4f55\u4fee\u6539\u5206\u652f\u540d\u3002 \u67e5\u770b\u5206\u652f \u5728\u4fee\u6539\u5206\u652f\u540d\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u77e5\u9053\u5f53\u524d\u6240\u6709\u7684\u5206\u652f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u672c\u5730\u7684\u6240\u6709\u5206\u652f\uff1a $ git branch \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u91cc\u4f1a\u7f57\u5217\u51fa\u6240\u6709\u7684\u672c\u5730\u5206\u652f\u7684\u5217\u8868\uff0c\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u6240\u5728\u7684\u5206\u652f\u524d\u9762\u4f1a\u6709\u4e00\u4e2a\u661f\u53f7\uff0c\u5982\u4e0b\u6240\u793a\uff1a master * dev feature-1 feature-2 \u767b\u5f55\u540e\u590d\u5236 \u4fee\u6539\u672c\u5730\u5206\u652f\u540d \u5728 Git \u4e2d\uff0c\u4fee\u6539\u5206\u652f\u540d\u4e3b\u8981\u6709\u4e09\u79cd\u65b9\u5f0f\uff0c\u5206\u522b\u662f\uff1a \u91cd\u547d\u540d\u5206\u652f \u5220\u9664\u5206\u652f\u518d\u521b\u5efa\u65b0\u7684\u5206\u652f \u521b\u5efa\u65b0\u7684\u5206\u652f\u518d\u5220\u9664\u65e7\u7684\u5206\u652f \u63a5\u4e0b\u6765\uff0c\u5c31\u6765\u4e00\u4e00\u4ecb\u7ecd\u8fd9\u4e09\u79cd\u65b9\u5f0f\u3002 2.1 \u91cd\u547d\u540d\u5206\u652f \u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u91cd\u547d\u540d\u5206\u652f\uff1a $ git branch -m &lt;old-branch-name&gt; &lt;new-branch-name&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c\u201c-m\u201d \u8868\u793a \u201cmove\u201d\uff0c\u5373\u79fb\u52a8\/\u91cd\u547d\u540d\u3002\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8bb0\u5f97\u5207\u6362\u5230\u5176\u4ed6\u5206\u652f\u8fdb\u884c\u64cd\u4f5c\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002 2.2 \u5220\u9664\u5206\u652f\u518d\u521b\u5efa\u65b0\u7684\u5206\u652f \u8be5\u65b9\u6cd5\u4e3b\u8981\u5206\u4e24\u6b65\u8fdb\u884c\uff1a \u5220\u9664\u65e7\u7684\u5206\u652f \u521b\u5efa\u65b0\u7684\u5206\u652f \u6b65\u9aa4\u4e00\uff0c\u5220\u9664\u65e7\u7684\u5206\u652f\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a $ git branch -d &lt;old-branch-name&gt; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u8be5\u547d\u4ee4\u4f1a\u5c06\u6307\u5b9a\u7684\u65e7\u5206\u652f\u5220\u9664\u3002 \u6b65\u9aa4\u4e8c\uff0c\u521b\u5efa\u65b0\u7684\u5206\u652f\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a $ git [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-19310","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=19310"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19310\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}