{"id":56798,"date":"2023-10-15T20:05:41","date_gmt":"2023-10-15T12:05:41","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=56798"},"modified":"2023-10-15T20:05:42","modified_gmt":"2023-10-15T12:05:42","slug":"%e8%af%a6%e8%a7%a3git%e5%a6%82%e4%bd%95%e6%8b%89%e5%88%86%e6%94%af","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/56798.html","title":{"rendered":"\u8be6\u89e3git\u5982\u4f55\u62c9\u5206\u652f"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\">\n<p>Git\u62c9\u5206\u652f\u6b65\u9aa4\uff1a1.\u521d\u59cb\u5316\u4ed3\u5e93\u548c\u514b\u9686\u5206\u652f\uff1b2.\u7406\u89e3\u5206\u652f\u7684\u672c\u8d28\uff1b3.\u521b\u5efa\u53ca\u5207\u6362\u5206\u652f\uff1b4.\u62c9\u53d6\u5206\u652f\uff1b5.\u5408\u5e76\u5206\u652f\uff1b6.\u89e3\u51b3\u51b2\u7a81\uff1b7.\u5206\u652f\u7b56\u7565\uff1b8.\u4fdd\u6301\u5206\u652f\u66f4\u65b0\uff1b9.\u5206\u652f\u7684\u5220\u9664\u3002\u5728\u65e5\u5e38\u7684\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u4f7f\u7528Git\u8fdb\u884c\u7248\u672c\u63a7\u5236\u53ca\u534f\u540c\u5de5\u4f5c\u6210\u4e3a\u4e86\u57fa\u672c\u7684\u5b9e\u8df5\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u521d\u59cb\u5316\u4ed3\u5e93\u548c\u514b\u9686\u5206\u652f<\/h2>\n\n\n\n<p>\u5728\u5f00\u59cb\u64cd\u4f5cGit\u5206\u652f\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u521d\u59cb\u5316\u4e00\u4e2aGit\u4ed3\u5e93\u6216\u8005\u514b\u9686\u4e00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\u5230\u672c\u5730\u3002\u5728\u5f00\u53d1\u56e2\u961f\u4e2d\uff0c\u901a\u5e38\u662f\u5728Git\u5e73\u53f0\uff08\u4f8b\u5982\uff1aGitHub, GitLab, Bitbucket\u7b49\uff09\u4e0a\u5df2\u7ecf\u521b\u5efa\u4e86\u9879\u76ee\u4ed3\u5e93\uff0c\u5f00\u53d1\u8005\u4eec\u514b\u9686(clone)\u8be5\u4ed3\u5e93\u5230\u672c\u5730\u8fdb\u884c\u5f00\u53d1\u3002\u901a\u8fc7 <strong>git clone [repository-url]<\/strong> \u547d\u4ee4\u6211\u4eec\u53ef\u4ee5\u628a\u8fdc\u7a0b\u4ed3\u5e93\u514b\u9686\u81f3\u672c\u5730\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u7406\u89e3\u5206\u652f\u7684\u672c\u8d28<\/h2>\n\n\n\n<p>\u5728\u6df1\u5165\u64cd\u4f5c\u524d\uff0c\u7406\u89e3Git\u5206\u652f\u7684\u6982\u5ff5\u4e0e\u5de5\u4f5c\u65b9\u5f0f\u81f3\u5173\u91cd\u8981\u3002\u5728Git\u4e2d\uff0c\u5206\u652f\u662f\u6307\u5411\u63d0\u4ea4\u5bf9\u8c61\u7684\u53ef\u53d8\u6307\u9488\u3002\u4e3b\u5206\u652f\uff08\u901a\u5e38\u547d\u540d\u4e3amain\u6216master\uff09\u662f\u9ed8\u8ba4\u7684\u5206\u652f\uff0c\u5f53\u6211\u4eec\u63d0\u4ea4\u66f4\u6539\u65f6\uff0c\u4e3b\u5206\u652f\u6307\u9488\u4f1a\u5411\u524d\u79fb\u52a8\u3002\u65b0\u521b\u5efa\u7684\u5206\u652f\u4e5f\u4f1a\u6709\u81ea\u5df1\u7684\u6307\u9488\uff0c\u5e76\u4e14\u5728\u63d0\u4ea4\u64cd\u4f5c\u65f6\u968f\u4e4b\u79fb\u52a8\u3002\u901a\u8fc7\u5206\u652f\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4e0d\u5e72\u6270\u4e3b\u5f00\u53d1\u7ebf\u7684\u524d\u63d0\u4e0b\uff0c\u5e73\u884c\u8fdb\u884c\u529f\u80fd\u5f00\u53d1\u6216bug\u4fee\u590d\u7b49\u4efb\u52a1\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u521b\u5efa\u53ca\u5207\u6362\u5206\u652f<\/h2>\n\n\n\n<p>\u4f7f\u7528 <strong>git branch [branch-name]<\/strong> \u547d\u4ee4\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u5206\u652f\uff0c\u8fd9\u4e0d\u4f1a\u6539\u53d8\u73b0\u6709\u5206\u652f\u4e0a\u7684\u4efb\u4f55\u5185\u5bb9\u3002\u5728\u8fd9\u4e2a\u65b0\u5206\u652f\u4e0a\u7684\u66f4\u6539\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u539f\u5206\u652f\u3002\u4e3a\u4e86\u5728\u65b0\u521b\u5efa\u7684\u5206\u652f\u4e0a\u5de5\u4f5c\uff0c\u6211\u4eec\u9700\u8981\u7528 <strong>git checkout [branch-name]<\/strong> \u547d\u4ee4\u5207\u6362\u5230\u8be5\u5206\u652f\u3002Git 2.23 \u7248\u672c\u540e\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528 <strong>git switch [branch-name]<\/strong> \u547d\u4ee4\u6765\u5207\u6362\u5206\u652f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4.\u62c9\u53d6\u5206\u652f<\/h2>\n\n\n\n<p>\u5f53\u56e2\u961f\u6210\u5458\u5728\u8fdc\u7a0b\u4ed3\u5e93\u521b\u5efa\u4e86\u65b0\u7684\u5206\u652f\u5e76\u63d0\u4ea4\u4e86\u4e00\u4e9b\u66f4\u6539\u540e\uff0c\u6211\u4eec\u9700\u8981\u7528 <strong>git fetch<\/strong> \u547d\u4ee4\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u65b0\u5206\u652f\u5230\u672c\u5730\uff0c\u7136\u540e\u4f7f\u7528 <strong>git checkout [branch-name]<\/strong> \u5207\u6362\u5230\u65b0\u5206\u652f\u3002\u5982\u679c\u672c\u5730\u6ca1\u6709\u8be5\u5206\u652f\uff0c<strong>git<\/strong> \u4f1a\u81ea\u52a8\u4e3a\u4f60\u521b\u5efa\u4e00\u4e2a\u8fdc\u7a0b\u5206\u652f\u7684\u8ddf\u8e2a\u5206\u652f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5.\u5408\u5e76\u5206\u652f<\/h2>\n\n\n\n<p>\u5f00\u53d1\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u628a\u65b0\u5206\u652f\u7684\u66f4\u6539\u5408\u5e76\u5230\u4e3b\u5206\u652f\u3002\u9996\u5148\u6211\u4eec\u8981\u5207\u6362\u5230\u4e3b\u5206\u652f\uff0c\u7136\u540e\u4f7f\u7528 <strong>git merge [branch-name]<\/strong> \u547d\u4ee4\u5c06\u65b0\u5206\u652f\u7684\u66f4\u6539\u5408\u5e76\u5230\u4e3b\u5206\u652f\u3002\u8fd9\u65f6\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u51b2\u7a81\uff0c\u9700\u8981\u624b\u52a8\u89e3\u51b3\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6.\u89e3\u51b3\u51b2\u7a81<\/h2>\n\n\n\n<p>\u5728\u5408\u5e76\u5206\u652f\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u51b2\u7a81\uff0c\u7279\u522b\u662f\u5f53\u591a\u4eba\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u4e0a\u8fdb\u884c\u66f4\u6539\u65f6\u3002Git\u4f1a\u6807\u8bb0\u51fa\u51b2\u7a81\u7684\u6587\u4ef6\uff0c\u6211\u4eec\u9700\u8981\u624b\u52a8\u6253\u5f00\u8fd9\u4e9b\u6587\u4ef6\uff0c\u627e\u5230\u7531Git\u63d2\u5165\u7684\u7279\u6b8a\u6807\u8bb0\u6807\u51fa\u7684\u51b2\u7a81\u533a\u57df\uff0c\u89e3\u51b3\u51b2\u7a81\u540e\uff0c\u63d0\u4ea4\u89e3\u51b3\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7.\u5206\u652f\u7b56\u7565<\/h2>\n\n\n\n<p>\u5728\u56e2\u961f\u534f\u4f5c\u4e2d\uff0c\u786e\u5b9a\u4e00\u4e2a\u6e05\u6670\u7684\u5206\u652f\u7b56\u7565\u662f\u5f88\u91cd\u8981\u7684\u3002\u901a\u5e38\u7684\u505a\u6cd5\u662f\u4e3b\u5206\u652f\u4ee3\u8868\u7a33\u5b9a\u7684\u53d1\u5e03\u7248\u672c\uff0c\u5f00\u53d1\u5206\u652f\u7528\u4e8e\u5f00\u53d1\u65b0\u529f\u80fd\uff0c\u540c\u65f6\u53ef\u80fd\u8fd8\u4f1a\u6709\u9488\u5bf9\u5177\u4f53\u65b0\u529f\u80fd\u6216\u8005bug\u4fee\u590d\u7684\u4e34\u65f6\u5206\u652f\u3002\u56e2\u961f\u6210\u5458\u5728\u8fd9\u4e9b\u4e34\u65f6\u5206\u652f\u4e0a\u5de5\u4f5c\uff0c\u5b8c\u6210\u540e\u5c06\u66f4\u6539\u5408\u5e76\u5230\u5f00\u53d1\u5206\u652f\uff0c\u518d\u5c06\u5f00\u53d1\u5206\u652f\u7684\u66f4\u6539\u5b9a\u671f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8.\u4fdd\u6301\u5206\u652f\u66f4\u65b0<\/h2>\n\n\n\n<p>\u5f53\u4e3b\u5206\u652f\u6216\u5176\u4ed6\u534f\u4f5c\u5206\u652f\u6709\u4e86\u65b0\u7684\u66f4\u65b0\u65f6\uff0c\u6211\u4eec\u9700\u8981\u65f6\u5e38\u540c\u6b65\u8fd9\u4e9b\u66f4\u65b0\u5230\u6211\u4eec\u6b63\u5728\u5de5\u4f5c\u7684\u5206\u652f\u4e0a\u3002\u4f7f\u7528<strong>git pull origin [branch-name]<\/strong>\u6216\u8005\u901a\u8fc7\u5148<strong>fetch<\/strong>\u518d<strong>merge<\/strong>\u7684\u65b9\u5f0f\u6765\u540c\u6b65\u8fdc\u7a0b\u5206\u652f\u7684\u66f4\u65b0\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9.\u5206\u652f\u7684\u5220\u9664<\/h2>\n\n\n\n<p>\u5206\u652f\u5b8c\u6210\u5b83\u7684\u4f7f\u547d\uff08\u5982\u7279\u6027\u5f00\u53d1\u5b8c\u6210\uff0cbug\u88ab\u4fee\u590d\u7b49\uff09\u540e\uff0c\u53ef\u4ee5\u8003\u8651\u5220\u9664\u5206\u652f\uff0c\u4fdd\u6301\u5de5\u4f5c\u76ee\u5f55\u7684\u6574\u6d01\u3002\u4f7f\u7528<strong>git branch -d [branch-name]<\/strong>\u547d\u4ee4\u53ef\u4ee5\u5220\u9664\u672c\u5730\u5206\u652f\uff0c\u6dfb\u52a0<strong>-r<\/strong>\u9009\u9879\u53ef\u4ee5\u5220\u9664\u8fdc\u7a0b\u5206\u652f\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u4ee5\u4e0a9\u4e2a\u65b9\u9762\u7684\u8be6\u7ec6\u89e3\u8bfb\uff0c\u65e0\u8bba\u4f60\u662f\u521a\u5165\u95e8\u7684\u65b0\u624b\uff0c\u8fd8\u662f\u6b63\u5728\u5bfb\u627e\u66f4\u9ad8\u6548\u5b9e\u8df5\u7684\u8d44\u6df1\u5f00\u53d1\u8005\uff0c\u90fd\u53ef\u4ee5\u5728\u65e5\u5e38\u7684Git\u64cd\u4f5c\u4e2d\uff0c\u5c24\u5176\u662f\u5206\u652f\u7ba1\u7406\u65b9\u9762\uff0c\u6e38\u5203\u6709\u4f59\uff0c\u8fdb\u800c\u63d0\u5347\u56e2\u961f\u7684\u534f\u4f5c\u6548\u7387\u548c\u9879\u76ee\u7684\u7ba1\u7406\u8d28\u91cf\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u7ed9\u4f60\u7684Git\u4e4b\u65c5\u5e26\u6765\u4fbf\u5229\u4e0e\u542f\u53d1\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1280\" height=\"850\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/10\/\u5982\u4f55\u4e0b\u8f7dgithub\u7684\u6587\u4ef6-87.jpg?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\" class=\"wp-image-56799\" srcset=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/10\/\u5982\u4f55\u4e0b\u8f7dgithub\u7684\u6587\u4ef6-87.jpg 1280w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/10\/\u5982\u4f55\u4e0b\u8f7dgithub\u7684\u6587\u4ef6-87-768x510.jpg 768w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/figure>\n\n\n\n<p><strong>\u5e38\u89c1\u95ee\u7b54\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>Q1: \u5982\u4f55\u514b\u9686\u8fdc\u7a0b\u4ed3\u5e93\u7684\u7279\u5b9a\u5206\u652f\u5230\u672c\u5730\uff1f<\/strong><\/li>\n\n\n\n<li><strong>A:<\/strong> \u53ef\u4ee5\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\u6765\u514b\u9686\u8fdc\u7a0b\u4ed3\u5e93\u7684\u7279\u5b9a\u5206\u652f\uff1agit clone -b [branch-name] [repository-url]\u5176\u4e2d<strong>[branch-name]<\/strong>\u662f\u4f60\u8981\u514b\u9686\u7684\u5206\u652f\u540d\u79f0\uff0c<strong>[repository-url]<\/strong>\u662f\u8fdc\u7a0b\u4ed3\u5e93\u7684URL\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Q2: \u6211\u5728\u672c\u5730\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u5206\u652f\u5e76\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5176\u4ed6\u56e2\u961f\u6210\u5458\u5982\u4f55\u83b7\u53d6\u8fd9\u4e2a\u65b0\u5206\u652f\uff1f<\/strong><\/li>\n\n\n\n<li><strong>A:<\/strong> \u5f53\u4f60\u7684\u56e2\u961f\u6210\u5458\u60f3\u8981\u83b7\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u4e0a\u7684\u65b0\u5206\u652f\u65f6\uff0c\u4ed6\u4eec\u9700\u8981\u9996\u5148\u4f7f\u7528 <strong>git fetch origin<\/strong> \u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u6240\u6709\u53d8\u5316\uff08\u5305\u62ec\u65b0\u7684\u5206\u652f\u4fe1\u606f\uff09\u3002\u7136\u540e\uff0c\u4ed6\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5207\u6362\u5230\u65b0\u7684\u5206\u652f\uff1agit checkout [branch-name]\u5176\u4e2d<strong>[branch-name]<\/strong>\u662f\u65b0\u5206\u652f\u7684\u540d\u79f0\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Q3: \u5408\u5e76\u5206\u652f\u65f6\u9047\u5230\u4e86\u51b2\u7a81\uff0c\u6211\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><\/li>\n\n\n\n<li><strong>A:<\/strong> \u5f53\u5408\u5e76\u5206\u652f\u65f6\u9047\u5230\u51b2\u7a81\uff0c\u4f60\u9700\u8981\u624b\u52a8\u89e3\u51b3\u8fd9\u4e9b\u51b2\u7a81\u3002\u9996\u5148\uff0c\u6253\u5f00\u5305\u542b\u51b2\u7a81\u7684\u6587\u4ef6\uff0c\u5e76\u627e\u5230\u7531Git\u6807\u8bb0\u7684\u51b2\u7a81\u533a\u57df\uff0c\u901a\u5e38\u5b83\u4eec\u5728<strong>&lt;&lt;&lt;&lt;&lt;&lt;&lt;<\/strong>\u548c<strong>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<\/strong>\u6807\u8bb0\u4e4b\u95f4\u3002\u4f60\u9700\u8981\u51b3\u5b9a\u4fdd\u7559\u54ea\u4e9b\u66f4\u6539\uff0c\u6216\u8005\u624b\u52a8\u7f16\u8f91\u4ee3\u7801\u5230\u671f\u671b\u7684\u72b6\u6001\u3002\u89e3\u51b3\u51b2\u7a81\u540e\uff0c\u4f60\u9700\u8981\u6267\u884c\u4e0b\u5217\u547d\u4ee4\u4ee5\u5b8c\u6210\u5408\u5e76\u8fc7\u7a0b\uff1agit add [conflicted-file] git commit\u5176\u4e2d<strong>[conflicted-file]<\/strong>\u662f\u89e3\u51b3\u4e86\u51b2\u7a81\u7684\u6587\u4ef6\u540d\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"Git\u62c9\u5206\u652f\u6b65\u9aa4\uff1a1.\u521d\u59cb\u5316\u4ed3\u5e93\u548c\u514b\u9686\u5206\u652f\uff1b2.\u7406\u89e3\u5206\u652f\u7684\u672c\u8d28\uff1b3.\u521b\u5efa\u53ca\u5207\u6362\u5206\u652f\uff1b4.\u62c9\u53d6\u5206\u652f\uff1b5.\u5408\u5e76\u5206\u652f [&hellip;]","protected":false},"author":7,"featured_media":56800,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[1163],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/56798"}],"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\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=56798"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/56798\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/56800"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=56798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=56798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=56798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}