{"id":53663,"date":"2023-09-17T22:42:54","date_gmt":"2023-09-17T14:42:54","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=53663"},"modified":"2023-09-17T23:04:15","modified_gmt":"2023-09-17T15:04:15","slug":"git%e5%88%86%e6%94%af%e6%80%8e%e4%b9%88%e5%90%88%e5%b9%b6%e5%88%b0%e4%b8%bb%e5%88%86%e6%94%af","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/53663.html","title":{"rendered":"git\u5206\u652f\u600e\u4e48\u5408\u5e76\u5230\u4e3b\u5206\u652f"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\">\n<p>git\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u7684\u6b65\u9aa4\uff1a1. \u521b\u5efa\u548c\u5207\u6362\u5206\u652f\uff1b2. \u5f00\u53d1\u5e76\u63d0\u4ea4\u66f4\u6539\uff1b3. \u66f4\u65b0\u4e3b\u5206\u652f\uff1b4. \u5408\u5e76\u5206\u652f\uff1b5. \u89e3\u51b3\u51b2\u7a81\uff1b6. \u63a8\u9001\u66f4\u6539\u3002\u5728Git\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>git checkout -b \u65b0\u5206\u652f\u540d<\/code>\u547d\u4ee4\u521b\u5efa\u65b0\u7684\u5206\u652f\u5e76\u5207\u6362\u5230\u8be5\u5206\u652f\u3002<\/p>\n<\/blockquote>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"680\" height=\"421\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/09\/13-2-1.png?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\" class=\"wp-image-53683\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">1. \u521b\u5efa\u548c\u5207\u6362\u5206\u652f<\/h2>\n\n\n\n<p>\u5728Git\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u65b0\u7684\u5206\u652f\u5e76\u5207\u6362\u5230\u8be5\u5206\u652f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout -b \u65b0\u5206\u652f\u540d<\/code><\/pre>\n\n\n\n<p>\u4f8b\u5982\uff0c\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cfeature\u201d\u7684\u65b0\u5206\u652f\u5e76\u5207\u6362\u5230\u5b83\uff0c\u53ef\u4ee5\u8fd0\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout -b feature\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u5c06\u4f7f\u60a8\u8fdb\u5165\u65b0\u5206\u652f\uff0c\u4ee5\u4fbf\u5728\u5176\u4e2d\u8fdb\u884c\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u5f00\u53d1\u5e76\u63d0\u4ea4\u66f4\u6539<\/h2>\n\n\n\n<p>\u5728\u65b0\u5206\u652f\u4e0a\u8fdb\u884c\u5f00\u53d1\u5de5\u4f5c\uff0c\u8fdb\u884c\u4ee3\u7801\u66f4\u6539\u5e76\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u63d0\u4ea4\u66f4\u6539\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git add .\ngit commit -m \"\u63d0\u4ea4\u4fe1\u606f\"\n<\/code><\/pre>\n\n\n\n<p>\u786e\u4fdd\u5728\u65b0\u5206\u652f\u4e0a\u4ed4\u7ec6\u6d4b\u8bd5\u548c\u9a8c\u8bc1\u60a8\u7684\u66f4\u6539\uff0c\u4ee5\u786e\u4fdd\u5b83\u4eec\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u66f4\u65b0\u4e3b\u5206\u652f<\/h2>\n\n\n\n<p>\u5728\u5408\u5e76\u5206\u652f\u4e4b\u524d\uff0c\u786e\u4fdd\u60a8\u7684\u4e3b\u5206\u652f\u662f\u6700\u65b0\u7684\u3002\u5207\u6362\u56de\u4e3b\u5206\u652f\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout main\ngit pull origin main\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u5c06\u786e\u4fdd\u60a8\u7684\u4e3b\u5206\u652f\u5305\u542b\u4e86\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e0a\u7684\u6700\u65b0\u66f4\u6539\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u5408\u5e76\u5206\u652f<\/h2>\n\n\n\n<p>\u5728\u4e3b\u5206\u652f\u4e0a\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u65b0\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git merge \u65b0\u5206\u652f\u540d\n<\/code><\/pre>\n\n\n\n<p>\u4f8b\u5982\uff0c\u8981\u5c06\u540d\u4e3a\u201cfeature\u201d\u7684\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\uff0c\u53ef\u4ee5\u8fd0\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git merge feature\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u6ca1\u6709\u51b2\u7a81\uff0cGit\u5c06\u81ea\u52a8\u5c06\u66f4\u6539\u5408\u5e76\u5230\u4e3b\u5206\u652f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u89e3\u51b3\u51b2\u7a81<\/h2>\n\n\n\n<p>\u5982\u679c\u5728\u5408\u5e76\u5206\u652f\u65f6\u53d1\u751f\u51b2\u7a81\uff0cGit\u5c06\u505c\u6b62\u5408\u5e76\u5e76\u6307\u793a\u60a8\u89e3\u51b3\u51b2\u7a81\u3002\u6253\u5f00\u51b2\u7a81\u6587\u4ef6\uff0c\u624b\u52a8\u7f16\u8f91\u4ee5\u89e3\u51b3\u51b2\u7a81\uff0c\u7136\u540e\u4f7f\u7528git add\u547d\u4ee4\u6807\u8bb0\u5df2\u89e3\u51b3\u7684\u6587\u4ef6\uff0c\u5e76\u8fd0\u884cgit commit\u4ee5\u5b8c\u6210\u5408\u5e76\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. \u63a8\u9001\u66f4\u6539<\/h2>\n\n\n\n<p>\u6700\u540e\uff0c\u5c06\u5408\u5e76\u540e\u7684\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u5b58\u50a8\u5e93\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git push origin main\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u5c06\u786e\u4fdd\u5176\u4ed6\u56e2\u961f\u6210\u5458\u53ef\u4ee5\u8bbf\u95ee\u60a8\u7684\u66f4\u6539\u3002<\/p>\n\n\n\n<p><strong>\u5e38\u89c1\u95ee\u7b54\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u95ee\uff1a\u6211\u5e94\u8be5\u4f55\u65f6\u5408\u5e76\u6211\u7684\u5206\u652f\u5230\u4e3b\u5206\u652f\uff1f<\/li>\n\n\n\n<li>\u7b54\uff1a\u60a8\u5e94\u8be5\u5728\u5206\u652f\u4e0a\u5b8c\u6210\u7279\u5b9a\u4efb\u52a1\u3001\u4fee\u590d\u9519\u8bef\u6216\u5b9e\u73b0\u67d0\u4e2a\u529f\u80fd\u540e\uff0c\u786e\u4fdd\u5728\u5408\u5e76\u4e4b\u524d\u8fdb\u884c\u5f7b\u5e95\u7684\u6d4b\u8bd5\u548c\u9a8c\u8bc1\u3002\u4e00\u65e6\u60a8\u786e\u4fe1\u60a8\u7684\u5206\u652f\u4ee3\u7801\u7a33\u5b9a\u53ef\u9760\uff0c\u5c31\u53ef\u4ee5\u5c06\u5176\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>\u95ee\uff1a\u5982\u4f55\u5904\u7406\u5206\u652f\u5408\u5e76\u65f6\u7684\u51b2\u7a81\uff1f<\/li>\n\n\n\n<li>\u7b54\uff1a\u51b2\u7a81\u662f\u4e0d\u53ef\u907f\u514d\u7684\uff0c\u7279\u522b\u662f\u5728\u591a\u4eba\u534f\u4f5c\u5f00\u53d1\u7684\u60c5\u51b5\u4e0b\u3002\u5f53\u51fa\u73b0\u51b2\u7a81\u65f6\uff0c\u60a8\u9700\u8981\u624b\u52a8\u89e3\u51b3\u51b2\u7a81\uff0c\u7f16\u8f91\u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u4ee5\u89e3\u51b3\u5dee\u5f02\u3002\u89e3\u51b3\u540e\uff0c\u4f7f\u7528git add\u547d\u4ee4\u6807\u8bb0\u5df2\u89e3\u51b3\u7684\u6587\u4ef6\uff0c\u7136\u540e\u63d0\u4ea4\u66f4\u6539\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>\u95ee\uff1a\u6211\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5206\u652f\u7684\u90e8\u5206\u66f4\u6539\u5408\u5e76\u5230\u4e3b\u5206\u652f\u5417\uff1f<\/li>\n\n\n\n<li>\u7b54\uff1a\u662f\u7684\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u6027\u5730\u5c06\u5206\u652f\u4e0a\u7684\u7279\u5b9a\u66f4\u6539\u5408\u5e76\u5230\u4e3b\u5206\u652f\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528git cherry-pick\u547d\u4ee4\u6765\u5b9e\u73b0\u3002\u4f46\u8bf7\u8c28\u614e\u64cd\u4f5c\uff0c\u786e\u4fdd\u60a8\u53ea\u9009\u62e9\u9700\u8981\u7684\u66f4\u6539\uff0c\u4ee5\u907f\u514d\u5f15\u5165\u4e0d\u5fc5\u8981\u7684\u590d\u6742\u6027\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"git\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u7684\u6b65\u9aa4\uff1a1. \u521b\u5efa\u548c\u5207\u6362\u5206\u652f\uff1b2. \u5f00\u53d1\u5e76\u63d0\u4ea4\u66f4\u6539\uff1b3. \u66f4\u65b0\u4e3b\u5206\u652f\uff1b4. \u5408\u5e76\u5206\u652f\uff1b5 [&hellip;]","protected":false},"author":4,"featured_media":53665,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[2469,2470,1163],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/53663"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=53663"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/53663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/53665"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=53663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=53663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=53663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}