{"id":4200,"date":"2019-10-18T11:59:23","date_gmt":"2019-10-18T03:59:23","guid":{"rendered":"http:\/\/switch.linesno.com\/?p=4200"},"modified":"2019-10-18T11:59:23","modified_gmt":"2019-10-18T03:59:23","slug":"git-%e5%88%86%e6%94%af%e5%bc%80%e5%8f%91%e8%a7%84%e8%8c%83","status":"publish","type":"post","link":"http:\/\/switch.linesno.com\/?p=4200","title":{"rendered":"Git \u5206\u652f\u5f00\u53d1\u89c4\u8303"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Git \u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\u3002\n\u4e3a\u89c4\u8303\u5f00\u53d1\uff0c\u4fdd\u6301\u4ee3\u7801\u63d0\u4ea4\u8bb0\u5f55\u4ee5\u53ca git \u5206\u652f\u7ed3\u6784\u6e05\u6670\uff0c\u65b9\u4fbf\u540e\u7eed\u7ef4\u62a4\uff0c\u73b0\u89c4\u8303 git \u7684\u76f8\u5173\u64cd\u4f5c\u3002<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/user-gold-cdn.xitu.io\/2018\/7\/9\/1647e5710a34f528?imageView2\/0\/w\/1280\/h\/960\/format\/webp\/ignore-error\/1\" alt=\"image\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5206\u652f\u7ba1\u7406<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5206\u652f\u547d\u540d<\/h3>\n\n\n\n<p><strong>master \u5206\u652f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>master \u4e3a\u4e3b\u5206\u652f\uff0c\u4e5f\u662f\u7528\u4e8e\u90e8\u7f72\u751f\u4ea7\u73af\u5883\u7684\u5206\u652f\uff0c\u786e\u4fddmaster\u5206\u652f\u7a33\u5b9a\u6027<\/li><li>master \u5206\u652f\u4e00\u822c\u7531develop\u4ee5\u53cahotfix\u5206\u652f\u5408\u5e76\uff0c\u4efb\u4f55\u65f6\u95f4\u90fd\u4e0d\u80fd\u76f4\u63a5\u4fee\u6539\u4ee3\u7801<\/li><\/ul>\n\n\n\n<p><strong>develop \u5206\u652f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>develop \u4e3a\u5f00\u53d1\u5206\u652f\uff0c\u59cb\u7ec8\u4fdd\u6301\u6700\u65b0\u5b8c\u6210\u4ee5\u53cabug\u4fee\u590d\u540e\u7684\u4ee3\u7801<\/li><li>\u4e00\u822c\u5f00\u53d1\u7684\u65b0\u529f\u80fd\u65f6\uff0cfeature\u5206\u652f\u90fd\u662f\u57fa\u4e8edevelop\u5206\u652f\u4e0b\u521b\u5efa\u7684<\/li><\/ul>\n\n\n\n<p><strong>feature \u5206\u652f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f00\u53d1\u65b0\u529f\u80fd\u65f6\uff0c\u4ee5develop\u4e3a\u57fa\u7840\u521b\u5efafeature\u5206\u652f<\/li><li>\u5206\u652f\u547d\u540d: feature\/ \u5f00\u5934\u7684\u4e3a\u7279\u6027\u5206\u652f\uff0c \u547d\u540d\u89c4\u5219: feature\/user_module\u3001 feature\/cart_module<\/li><\/ul>\n\n\n\n<p><strong>release\u5206\u652f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>release \u4e3a\u9884\u4e0a\u7ebf\u5206\u652f\uff0c\u53d1\u5e03\u63d0\u6d4b\u9636\u6bb5\uff0c\u4f1arelease\u5206\u652f\u4ee3\u7801\u4e3a\u57fa\u51c6\u63d0\u6d4b<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5f53\u6709\u4e00\u7ec4feature\u5f00\u53d1\u5b8c\u6210\uff0c\u9996\u5148\u4f1a\u5408\u5e76\u5230develop\u5206\u652f\uff0c\u8fdb\u5165\u63d0\u6d4b\u65f6\uff0c\u4f1a\u521b\u5efarelease\u5206\u652f\u3002\n\u5982\u679c\u6d4b\u8bd5\u8fc7\u7a0b\u4e2d\u82e5\u5b58\u5728bug\u9700\u8981\u4fee\u590d\uff0c\u5219\u76f4\u63a5\u7531\u5f00\u53d1\u8005\u5728release\u5206\u652f\u4fee\u590d\u5e76\u63d0\u4ea4\u3002\n\u5f53\u6d4b\u8bd5\u5b8c\u6210\u4e4b\u540e\uff0c\u5408\u5e76release\u5206\u652f\u5230master\u548cdevelop\u5206\u652f\uff0c\u6b64\u65f6master\u4e3a\u6700\u65b0\u4ee3\u7801\uff0c\u7528\u4f5c\u4e0a\u7ebf\u3002\n\u590d\u5236\u4ee3\u7801<\/code><\/pre>\n\n\n\n<p><strong>hotfix \u5206\u652f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5206\u652f\u547d\u540d: hotfix\/ \u5f00\u5934\u7684\u4e3a\u4fee\u590d\u5206\u652f\uff0c\u5b83\u7684\u547d\u540d\u89c4\u5219\u4e0e feature \u5206\u652f\u7c7b\u4f3c<\/li><li>\u7ebf\u4e0a\u51fa\u73b0\u7d27\u6025\u95ee\u9898\u65f6\uff0c\u9700\u8981\u53ca\u65f6\u4fee\u590d\uff0c\u4ee5master\u5206\u652f\u4e3a\u57fa\u7ebf\uff0c\u521b\u5efahotfix\u5206\u652f\uff0c\u4fee\u590d\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5408\u5e76\u5230master\u5206\u652f\u548cdevelop\u5206\u652f<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u89c1\u4efb\u52a1<\/h3>\n\n\n\n<p><strong>\u589e\u52a0\u65b0\u529f\u80fd<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(dev)$: git checkout -b feature\/xxx            # \u4ecedev\u5efa\u7acb\u7279\u6027\u5206\u652f\n(feature\/xxx)$: blabla                         # \u5f00\u53d1\n(feature\/xxx)$: git add xxx\n(feature\/xxx)$: git commit -m 'commit comment'\n(dev)$: git merge feature\/xxx --no-ff          # \u628a\u7279\u6027\u5206\u652f\u5408\u5e76\u5230dev\n\u590d\u5236\u4ee3\u7801<\/code><\/pre>\n\n\n\n<p><strong>\u4fee\u590d\u7d27\u6025bug<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(master)$: git checkout -b hotfix\/xxx         # \u4ecemaster\u5efa\u7acbhotfix\u5206\u652f\n(hotfix\/xxx)$: blabla                         # \u5f00\u53d1\n(hotfix\/xxx)$: git add xxx\n(hotfix\/xxx)$: git commit -m 'commit comment'\n(master)$: git merge hotfix\/xxx --no-ff       # \u628ahotfix\u5206\u652f\u5408\u5e76\u5230master\uff0c\u5e76\u4e0a\u7ebf\u5230\u751f\u4ea7\u73af\u5883\n(dev)$: git merge hotfix\/xxx --no-ff          # \u628ahotfix\u5206\u652f\u5408\u5e76\u5230dev\uff0c\u540c\u6b65\u4ee3\u7801\n\u590d\u5236\u4ee3\u7801<\/code><\/pre>\n\n\n\n<p><strong>\u6d4b\u8bd5\u73af\u5883\u4ee3\u7801<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(release)$: git merge dev --no-ff             # \u628adev\u5206\u652f\u5408\u5e76\u5230release\uff0c\u7136\u540e\u5728\u6d4b\u8bd5\u73af\u5883\u62c9\u53d6\u5e76\u6d4b\u8bd5\n\u590d\u5236\u4ee3\u7801<\/code><\/pre>\n\n\n\n<p><strong>\u751f\u4ea7\u73af\u5883\u4e0a\u7ebf<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(master)$: git merge release --no-ff          # \u628arelease\u6d4b\u8bd5\u597d\u7684\u4ee3\u7801\u5408\u5e76\u5230master\uff0c\u8fd0\u7ef4\u4eba\u5458\u64cd\u4f5c\n(master)$: git tag -a v0.1 -m '\u90e8\u7f72\u5305\u7248\u672c\u540d'  #\u7ed9\u7248\u672c\u547d\u540d\uff0c\u6253Tag\n\u590d\u5236\u4ee3\u7801<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/user-gold-cdn.xitu.io\/2018\/7\/9\/1647e5710a461adc?imageView2\/0\/w\/1280\/h\/960\/format\/webp\/ignore-error\/1\" alt=\"image\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u65e5\u5fd7\u89c4\u8303<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5728\u4e00\u4e2a\u56e2\u961f\u534f\u4f5c\u7684\u9879\u76ee\u4e2d\uff0c\u5f00\u53d1\u4eba\u5458\u9700\u8981\u7ecf\u5e38\u63d0\u4ea4\u4e00\u4e9b\u4ee3\u7801\u53bb\u4fee\u590dbug\u6216\u8005\u5b9e\u73b0\u65b0\u7684feature\u3002\u800c\u9879\u76ee\u4e2d\u7684\u6587\u4ef6\u548c\u5b9e\u73b0\u4ec0\u4e48\u529f\u80fd\u3001\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u90fd\u4f1a\u6e10\u6e10\u6de1\u5fd8\uff0c\u6700\u540e\u9700\u8981\u6d6a\u8d39\u65f6\u95f4\u53bb\u9605\u8bfb\u4ee3\u7801\u3002\u4f46\u662f\u597d\u7684\u65e5\u5fd7\u89c4\u8303commit messages\u7f16\u5199\u6709\u5e2e\u52a9\u5230\u6211\u4eec\uff0c\u5b83\u4e5f\u53cd\u6620\u4e86\u4e00\u4e2a\u5f00\u53d1\u4eba\u5458\u662f\u5426\u662f\u826f\u597d\u7684\u534f\u4f5c\u8005\u3002<\/p><\/blockquote>\n\n\n\n<p><strong>\u7f16\u5199\u826f\u597d\u7684Commit messages\u53ef\u4ee5\u8fbe\u52303\u4e2a\u91cd\u8981\u7684\u76ee\u7684\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u52a0\u5febreview\u7684\u6d41\u7a0b<\/li><li>\u5e2e\u52a9\u6211\u4eec\u7f16\u5199\u826f\u597d\u7684\u7248\u672c\u53d1\u5e03\u65e5\u5fd7<\/li><li>\u8ba9\u4e4b\u540e\u7684\u7ef4\u62a4\u8005\u4e86\u89e3\u4ee3\u7801\u91cc\u51fa\u73b0\u7279\u5b9a\u53d8\u5316\u548cfeature\u88ab\u6dfb\u52a0\u7684\u539f\u56e0<\/li><\/ul>\n\n\n\n<p><strong>\u76ee\u524d\uff0c\u793e\u533a\u6709\u591a\u79cd Commit message \u7684\u5199\u6cd5\u89c4\u8303\u3002\u6765\u81eaAngular \u89c4\u8303\u662f\u76ee\u524d\u4f7f\u7528\u6700\u5e7f\u7684\u5199\u6cd5\uff0c\u6bd4\u8f83\u5408\u7406\u548c\u7cfb\u7edf\u5316\u3002\u5982\u4e0b\u56fe\uff1a<\/strong>\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/user-gold-cdn.xitu.io\/2018\/7\/9\/1647e5710a492823?imageView2\/0\/w\/1280\/h\/960\/format\/webp\/ignore-error\/1\" alt=\"image\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Commit messages\u7684\u57fa\u672c\u8bed\u6cd5<\/h3>\n\n\n\n<p>\u5f53\u524d\u4e1a\u754c\u5e94\u7528\u7684\u6bd4\u8f83\u5e7f\u6cdb\u7684\u662f <a target=\"_blank\" href=\"https:\/\/github.com\/angular\/angular.js\/blob\/master\/DEVELOPERS.md#-git-commit-guidelines\" rel=\"noreferrer noopener\">Angular Git Commit Guidelines<\/a><\/p>\n\n\n\n<p>\u5177\u4f53\u683c\u5f0f\u4e3a:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;type>: &lt;subject>\n&lt;BLANK LINE>\n&lt;body>\n&lt;BLANK LINE>\n&lt;footer>\n\u590d\u5236\u4ee3\u7801<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>type: \u672c\u6b21 commit \u7684\u7c7b\u578b\uff0c\u8bf8\u5982 bugfix docs style \u7b49<\/li><li>scope: \u672c\u6b21 commit \u6ce2\u53ca\u7684\u8303\u56f4<\/li><li>subject: \u7b80\u660e\u627c\u8981\u7684\u9610\u8ff0\u4e0b\u672c\u6b21 commit \u7684\u4e3b\u65e8\uff0c\u5728\u539f\u6587\u4e2d\u7279\u610f\u5f3a\u8c03\u4e86\u51e0\u70b9 1. \u4f7f\u7528\u7948\u4f7f\u53e5\uff0c\u662f\u4e0d\u662f\u5f88\u719f\u6089\u53c8\u964c\u751f\u7684\u4e00\u4e2a\u8bcd\uff0c\u6765\u4f20\u9001\u95e8\u5728\u6b64 \u7948\u4f7f\u53e5 2. \u9996\u5b57\u6bcd\u4e0d\u8981\u5927\u5199 3. \u7ed3\u5c3e\u65e0\u9700\u6dfb\u52a0\u6807\u70b9<\/li><li>body: \u540c\u6837\u4f7f\u7528\u7948\u4f7f\u53e5\uff0c\u5728\u4e3b\u4f53\u5185\u5bb9\u4e2d\u6211\u4eec\u9700\u8981\u628a\u672c\u6b21 commit \u8be6\u7ec6\u7684\u63cf\u8ff0\u4e00\u4e0b\uff0c\u6bd4\u5982\u6b64\u6b21\u53d8\u66f4\u7684\u52a8\u673a\uff0c\u5982\u9700\u6362\u884c\uff0c\u5219\u4f7f\u7528 |<\/li><li>footer: \u63cf\u8ff0\u4e0b\u4e0e\u4e4b\u5173\u8054\u7684 issue \u6216 break change\uff0c\u8be6\u89c1\u6848\u4f8b<\/li><\/ul>\n\n\n\n<p><strong>Type\u7684\u7c7b\u522b\u8bf4\u660e\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>feat: \u6dfb\u52a0\u65b0\u7279\u6027<\/li><li>fix: \u4fee\u590dbug<\/li><li>docs: \u4ec5\u4ec5\u4fee\u6539\u4e86\u6587\u6863<\/li><li>style: \u4ec5\u4ec5\u4fee\u6539\u4e86\u7a7a\u683c\u3001\u683c\u5f0f\u7f29\u8fdb\u3001\u90fd\u597d\u7b49\u7b49\uff0c\u4e0d\u6539\u53d8\u4ee3\u7801\u903b\u8f91<\/li><li>refactor: \u4ee3\u7801\u91cd\u6784\uff0c\u6ca1\u6709\u52a0\u65b0\u529f\u80fd\u6216\u8005\u4fee\u590dbug<\/li><li>perf: \u589e\u52a0\u4ee3\u7801\u8fdb\u884c\u6027\u80fd\u6d4b\u8bd5<\/li><li>test: \u589e\u52a0\u6d4b\u8bd5\u7528\u4f8b<\/li><li>chore: \u6539\u53d8\u6784\u5efa\u6d41\u7a0b\u3001\u6216\u8005\u589e\u52a0\u4f9d\u8d56\u5e93\u3001\u5de5\u5177\u7b49<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Commit messages\u683c\u5f0f\u8981\u6c42<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u6807\u9898\u884c\uff1a50\u4e2a\u5b57\u7b26\u4ee5\u5185\uff0c\u63cf\u8ff0\u4e3b\u8981\u53d8\u66f4\u5185\u5bb9\n#\n# \u4e3b\u4f53\u5185\u5bb9\uff1a\u66f4\u8be6\u7ec6\u7684\u8bf4\u660e\u6587\u672c\uff0c\u5efa\u8bae72\u4e2a\u5b57\u7b26\u4ee5\u5185\u3002 \u9700\u8981\u63cf\u8ff0\u7684\u4fe1\u606f\u5305\u62ec:\n#\n# * \u4e3a\u4ec0\u4e48\u8fd9\u4e2a\u53d8\u66f4\u662f\u5fc5\u987b\u7684? \u5b83\u53ef\u80fd\u662f\u7528\u6765\u4fee\u590d\u4e00\u4e2abug\uff0c\u589e\u52a0\u4e00\u4e2afeature\uff0c\u63d0\u5347\u6027\u80fd\u3001\u53ef\u9760\u6027\u3001\u7a33\u5b9a\u6027\u7b49\u7b49\n# * \u4ed6\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898? \u5177\u4f53\u63cf\u8ff0\u89e3\u51b3\u95ee\u9898\u7684\u6b65\u9aa4\n# * \u662f\u5426\u5b58\u5728\u526f\u4f5c\u7528\u3001\u98ce\u9669? \n#\n# \u5982\u679c\u9700\u8981\u7684\u5316\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u94fe\u63a5\u5230issue\u5730\u5740\u6216\u8005\u5176\u5b83\u6587\u6863\n\u590d\u5236\u4ee3\u7801<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u94fe\u63a5<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a target=\"_blank\" href=\"http:\/\/www.ruanyifeng.com\/blog\/2012\/07\/git.html\" rel=\"noreferrer noopener\">Git\u5206\u652f\u7ba1\u7406\u7b56\u7565<\/a><\/li><li><a target=\"_blank\" href=\"http:\/\/ivweb.io\/topic\/58abda9d2117ae2f4995b4a8\" rel=\"noreferrer noopener\">\u5982\u4f55\u5199\u597d Git commit messages<\/a><\/li><li><a target=\"_blank\" href=\"https:\/\/segmentfault.com\/a\/1190000009048911\" rel=\"noreferrer noopener\">git commit \u89c4\u8303\u6307\u5357<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Git \u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\u3002 \u4e3a\u89c4\u8303\u5f00\u53d1\uff0c\u4fdd\u6301\u4ee3\u7801\u63d0\u4ea4\u8bb0\u5f55\u4ee5\u53ca git \u5206\u652f\u7ed3\u6784\u6e05\u6670\uff0c\u65b9\u4fbf\u540e\u7eed\u7ef4\u62a4\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-4200","post","type-post","status-publish","format-standard","hentry","category-day"],"_links":{"self":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts\/4200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4200"}],"version-history":[{"count":1,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts\/4200\/revisions"}],"predecessor-version":[{"id":4201,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=\/wp\/v2\/posts\/4200\/revisions\/4201"}],"wp:attachment":[{"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4200"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/switch.linesno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}