{"id":5140,"date":"2011-02-13T15:27:57","date_gmt":"2011-02-13T07:27:57","guid":{"rendered":"http:\/\/ihower.tw\/blog\/?p=5140"},"modified":"2011-04-27T22:15:13","modified_gmt":"2011-04-27T14:15:13","slug":"git-flow","status":"publish","type":"post","link":"https:\/\/ihower.tw\/blog\/5140-git-flow","title":{"rendered":"Git flow \u958b\u767c\u6d41\u7a0b"},"content":{"rendered":"<p>Update: 2011\/3\/19 \u53d7\u9080\u6709\u5834\u5206\u4eab <a href=\"\/blog\/archives\/5391\">Git\u4ecb\u7d39,\u4f7f\u7528\u8207\u958b\u767c\u6d41\u7a0b at Facebook \u8edf\u9ad4\u958b\u767c\u5718\u968a\u5de5\u5177\u5fc3\u5f97\u5206\u4eab<\/a><\/p>\n<p>\u5927\u5bb6\u90fd\u77e5\u9053 Git \u958b branch \u5f88\u65b9\u4fbf\uff0c\u975e\u5e38\u9f13\u52f5 topic branch\uff0c\u4f46\u6709\u6c92\u6709\u4e00\u5957\u6a21\u578b\u6d41\u7a0b\u544a\u8a34\u6211\u5011\u61c9\u8a72\u600e\u9ebc\u7ba1\u7406 branch \u5462? \u6709\u4eba\u4fbf\u6574\u7406\u51fa\u4e00\u5957\u6700\u4f73\u5be6\u8e10\u6163\u4f8b <a href=\"http:\/\/nvie.com\/posts\/a-successful-git-branching-model\/\">A successful Git branching model<\/a>\uff0c<a href=\"http:\/\/optimisdev.com\/\">\u6211\u5011\u5718\u968a<\/a>\u5c31\u63a1\u7528\u4e86\u9019\u5957\u6d41\u7a0b\u3002\u7c21\u55ae\u4f86\u8aaa\uff0c\u4ed6\u5c07 branch \u5206\u6210\u5169\u500b\u4e3b\u8981\u5206\u652f\uff0c\u4e09\u7a2e\u652f\u63f4\u6027\u5206\u652f\uff1a<\/p>\n<p><a href=\"http:\/\/nvie.com\/posts\/a-successful-git-branching-model\/\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"5183\" data-permalink=\"https:\/\/ihower.tw\/blog\/5140-git-flow\/screen-shot-2009-12-24-at-11-32-03\" data-orig-file=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/Screen-shot-2009-12-24-at-11.32.03.png\" data-orig-size=\"611,815\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Screen-shot-2009-12-24-at-11.32.03\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/Screen-shot-2009-12-24-at-11.32.03-224x300.png\" data-large-file=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/Screen-shot-2009-12-24-at-11.32.03.png\" src=\"http:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/Screen-shot-2009-12-24-at-11.32.03.png\"  width=\"611\" height=\"815\" class=\"alignnone size-full wp-image-5183\" srcset=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/Screen-shot-2009-12-24-at-11.32.03.png 611w, https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/Screen-shot-2009-12-24-at-11.32.03-224x300.png 224w\" sizes=\"auto, (max-width: 611px) 100vw, 611px\" \/><\/a><\/p>\n<ul>\n<li>\u4e3b\u8981\u5206\u652f\n<ul>\n<li>master: \u6c38\u9060\u8655\u5728 production-ready \u72c0\u614b<\/li>\n<li>develop: \u6700\u65b0\u7684\u4e0b\u6b21\u767c\u4f48\u958b\u767c\u72c0\u614b<\/li>\n<\/ul>\n<\/li>\n<li>\u652f\u63f4\u6027\u5206\u652f\n<ul>\n<li>Feature branches: \u958b\u767c\u65b0\u529f\u80fd\u90fd\u5f9e develop \u5206\u652f\u51fa\u4f86\uff0c\u5b8c\u6210\u5f8c merge \u56de develop<\/li>\n<li>Release branches: \u6e96\u5099\u8981 release \u7684\u7248\u672c\uff0c\u53ea\u4fee bugs\u3002\u5f9e develop \u5206\u652f\u51fa\u4f86\uff0c\u5b8c\u6210\u5f8c merge \u56de master \u548c develop<\/li>\n<li>Hotfix branches: \u7b49\u4e0d\u53ca release \u7248\u672c\u5c31\u5fc5\u9808\u99ac\u4e0a\u4fee master \u8d95\u4e0a\u7dda\u7684\u60c5\u6cc1\u3002\u6703\u5f9e master \u5206\u652f\u51fa\u4f86\uff0c\u5b8c\u6210\u5f8c merge \u56de master \u548c develop<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4f5c\u8005\u9084\u63d0\u4f9b\u4e86 <a href=\"https:\/\/github.com\/nvie\/gitflow\">git-flow<\/a> \u6307\u4ee4\u5de5\u5177\u5e6b\u52a9\u6211\u5011\u5f88\u5bb9\u6613\u7684\u5be6\u8e10\uff0c\u7528\u6cd5\u5982\u4e0b:<br \/>\n<!--more--><br \/>\n\u9996\u5148\u662f\u521d\u59cb\u5316\u52d5\u4f5c\uff1a<\/p>\n<pre>\r\n<code>\r\n    git flow init\r\n<\/code>\r\n<\/pre>\n<p>\u521d\u59cb\u5316\u52d5\u4f5c\u6703\u554f\u4f60\u4e00\u4e9b\u554f\u984c\uff0c\u5927\u62b5\u662f\u547d\u540d\u6163\u4f8b\uff1a<\/p>\n<pre>\r\n<code>\r\nNo branches exist yet. Base branches must be created now.\r\nBranch name for production releases: [master] \r\nBranch name for \"next release\" development: [develop] \r\nHow to name your supporting branch prefixes?\r\nFeature branches? [feature\/] \r\nRelease branches? [release\/] \r\nHotfix branches? [hotfix\/] \r\nSupport branches? [support\/] \r\nVersion tag prefix? []\r\n<\/code>\r\n<\/pre>\n<p>\u8a2d\u5b9a\u5b8c\u4e4b\u5f8c\uff0c\u9810\u8a2d\u7684 branch \u5c31\u8b8a\u6210 develop \u4e86\u3002\u6709\u4efb\u4f55\u958b\u767c\uff0c\u4e00\u5f8b\u90fd\u5148\u958b branch\uff1a<\/p>\n<pre>\r\n<code>\r\ngit flow feature start some_awesome_feature\r\n(\u4ee5\u6b64\u985e\u63a8 git flow release \u548c git flow hotfix)\r\n<\/code>\r\n<\/pre>\n<p>\u5b8c\u6210\u4e4b\u5f8c\u8f38\u5165<\/p>\n<pre>\r\n<code>\r\ngit flow feature finish some_awesome_feature\r\n<\/code>\r\n<\/pre>\n<p>\u5c31\u6703\u5408\u4f75\u56de develop \u4e26\u5e6b\u4f60\u522a\u9664\u9019\u500b (local) branch\u3002<\/p>\n<h3>\u95dc\u65bc remote branch<\/h3>\n<p><del>\u9019\u500b git-flow \u5de5\u5177\u4e26\u6c92\u6709\u5e6b\u6211\u5011\u8655\u7406 remote branch\uff0c\u6240\u4ee5\u5982\u679c\u4f60\u7684 branch \u8981 push \u51fa\u53bb\u5206\u4eab\u7d66\u5225\u4eba\uff0c\u5c31\u8981\u81ea\u5df1\u6253 git \u6307\u4ee4\u5566<\/del> \u540c\u4e8b\u7559\u8a00\u8aaa\u6709\u652f\u63f4\u5566\uff1a<\/p>\n<p>push \u4e00\u500b feature branch \u5230\u9060\u7aef\uff1a<\/p>\n<pre>\r\n<code>\r\ngit flow feature publish some_awesome_feature \r\n\u6216 git push origin feature\/some_awesome_feature\r\n<\/code>\r\n<\/pre>\n<p>\u8ffd\u8e64\u4e00\u500b\u9060\u7aef\u7684 branch\uff1a<\/p>\n<pre>\r\n<code>\r\ngit flow feature track some_awesome_feature \r\n\u6216 git checkout -b feature\/some_awesome_feature -t origin\/feature\/some_awesome_feature\r\n<\/code>\r\n<\/pre>\n<p>\u522a\u9664\u9060\u7aef\u7684 branch\uff1a<\/p>\n<pre>\r\n<code>\r\ngit push origin :feature\/some_awesome_feature\r\n<\/code>\r\n<\/pre>\n<p><a href=\"http:\/\/optimisdev.com\/\">\u6211\u5011<\/a>\u9084\u78b0\u5230\u4e00\u500b\u554f\u984c\u662f\u8f38\u5165 git flow feature finish \u6642\u51fa\u73fe\u4ee5\u4e0b\u932f\u8aa4\uff1a<\/p>\n<pre>\r\n<code>\r\nwarning: not deleting branch 'feature\/some_awesome_feature' that is not yet merged to\r\n         'refs\/remotes\/origin\/feature\/some_awesome_feature', even though it is merged to HEAD.\r\nerror: The branch 'feature\/some_awesome_feature' is not fully merged.\r\nIf you are sure you want to delete it, run 'git branch -D feature\/some_awesome_feature'.\r\n<\/code>\r\n<\/pre>\n<p>\u539f\u56e0\u662f\u9019\u500b feature branch \u4e00\u958b\u59cb\u662f\u5f9e\u9060\u7aef checkout \u51fa\u4f86\u7684\uff0c\u4ee5\u53ca\u9019\u500b feature branch \u6709 commit \u6c92\u6709 push \u56de\u53bb \uff0c\u6240\u4ee5 git flow \u4e0d\u6562\u5e6b\u4f60\u522a\u9664 local branch\uff0c\u9019\u6642\u5019\u5176\u5be6 merge \u52d5\u4f5c\u5df2\u7d93\u5b8c\u6210\u4e86\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u624b\u52d5\u8f38\u5165 git branch -D feature\/some_awesome_feature \u5f37\u5236\u522a\u9664 local branch \u5373\u53ef\u3002(\u5c0f\u7d50\u8ad6\uff1agit-flow \u53ea\u662f\u500b\u8f14\u52a9\u5de5\u5177\uff0c\u4e86\u89e3 git \u9084\u662f\u5fc5\u8981\u7684)<\/p>\n<h3>\u95dc\u65bc feature branch \u7684\u5408\u4f75<\/h3>\n<p>\u5982\u679c\u662f\u958b\u767c\u6642\u9593\u6bd4\u8f03\u4e45\u7684 feature branch\uff0c\u5f88\u53ef\u80fd\u6703\u56e0\u70ba 1. \u4e0d\u5b9a\u6642\u7684 merge develop \u8207\u65b0\u7248\u540c\u6b65 2. \u5be6\u9a57\u6027\u8cea\u7684\u4fee\u6539 3. \u9700\u6c42\u7684\u8b8a\u66f4 \u7b49\u7b49\u56e0\u7d20\uff0c\u800c\u8b93\u9019\u500b feature branch \u7684 commit \u8a18\u9304\u8b8a\u6210\u9ad2\u9ad2\u7684\uff0c\u9019\u6642\u5019<a href=\"http:\/\/optimisdev.com\/\">\u6211\u5011<\/a>\u6703\u7528\u4ee5\u4e0b\u7684\u65b9\u5f0f\u4f86\u505a merge \u52d5\u4f5c\uff1a<\/p>\n<p>1. \u5148\u5c0d feature branch \u505a `git rebase develop`\u3002\u6703\u5f88\u82e6\uff0c\u4f46\u662f\u5f04\u5b8c\u6703\u5f88\u6709\u6210\u5c31\u611f\uff0c\u6574\u500b branch commit history \u6703\u8b8a\u6210\u5f88\u4e7e\u6de8\u3002\u8acb\u5b78 interactive mode\uff0c\u53ef\u4ee5\u8b93\u4f60\u62ff\u6389\u4e00\u4e9b commit\u3001\u5408\u4f75\u6216\u4fee\u6539\uff0c\u4f60\u4e5f\u53ef\u4ee5 rebase \u591a\u6b21\u76f4\u5230\u6eff\u610f\u70ba\u6b62\u3002<br \/>\n2. \u5728\u5f9e develop bracnh \u505a `git merge feature\/some_awesome_feature &#8211;no-ff`\uff0c&#8211;no-ff \u7684\u610f\u601d\u662f\u6703\u5f37\u5236\u7559\u4e00\u500b merge commit log \u8a18\u9304\uff0c\u9019\u53ef\u4ee5\u8b93 commit tree \u770b\u6e05\u695a\u767c\u751f\u4e86 merge \u52d5\u4f5c\u3002(\u56e0\u70ba\u6211\u5011\u525b\u505a\u4e86 rebase\uff0c\u800c git \u9810\u8a2d\u7684\u5408\u4f75\u6a21\u5f0f\u662f fast-forward\uff0c\u6240\u4ee5\u5982\u679c\u4e0d\u52a0 &#8211;no-ff \u662f\u4e0d\u6703\u6709 merge commit \u7684) \u9019\u500b merge commit \u7684\u53e6\u4e00\u500b\u984d\u5916\u65b9\u4fbf\u4e4b\u8655\u662f\uff0c\u5982\u679c\u60f3\u8981 reset\/revert \u6574\u500b branch \u53ea\u8981 reset\/revert \u9019\u500b commit \u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\n3. \u5982\u679c\u6b64 feature branch \u6709 remote branch\uff0c\u8981\u5148\u780d\u6389 `git push origin :feature\/some_awesome_feature` \u518d `git push origin develop` (\u9019\u662f\u56e0\u70ba rebase \u4e00\u500b\u5df2\u7d93 push \u51fa\u53bb\u7684 repository\uff0c\u7136\u5f8c\u53c8\u628a\u4fee\u6539\u7684 history push \u51fa\u53bb\uff0c\u6703\u9020\u6210\u8d85\u7d1a\u5927\u707d\u96e3\u554a~)<\/p>\n<p>\u5148 rebase \u518d merge &#8211;no-ff \u9019\u6a23\u505a\u7684\u597d\u8655\u5230\u5e95\u662f\u4ec0\u9ebc? \u770b\u5716\u9ad4\u6703\u4e00\u4e0b\u5427\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"5172\" data-permalink=\"https:\/\/ihower.tw\/blog\/5140-git-flow\/git-branch-2\" data-orig-file=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/git-branch1.jpg\" data-orig-size=\"574,347\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"git-branch\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/git-branch1-300x181.jpg\" data-large-file=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/git-branch1.jpg\" src=\"http:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/git-branch1.jpg\" alt=\"\" title=\"git-branch\" width=\"574\" height=\"347\" class=\"alignnone size-full wp-image-5172\" srcset=\"https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/git-branch1.jpg 574w, https:\/\/ihower.tw\/blog\/wp-content\/uploads\/2011\/02\/git-branch1-300x181.jpg 300w\" sizes=\"auto, (max-width: 574px) 100vw, 574px\" \/><\/p>\n<p>\u6bcf\u4e00\u6b21\u7684 merge \u5c31\u4ee3\u8868\u4e86\u4e00\u500b feature \u5b8c\u6210\uff0c\u4e5f\u53ef\u4ee5\u5f88\u6e05\u695a\u770b\u5230\u9019\u500b feature branch \u5e95\u4e0b\u5305\u542b\u54ea\u4e9b commit\u3002<\/p>\n<p>\u5c0d\u4e86\uff0c\u5982\u679c\u6709\u7528 Github \u7684\u8a71\uff0c\u8acb\u8a18\u5f97\u52d9\u5fc5\u7528\u4e00\u7528\u5b83\u7684 <a href=\"https:\/\/github.com\/blog\/785-pull-request-diff-comments\">pull request<\/a> \u529f\u80fd\uff0c\u6211\u5011\u6703\u5728 branch \u5b8c\u6210\u5f8c\u767c\u4e00\u500b pull request\uff0c\u597d\u8b93\u5927\u5bb6\u53ef\u4ee5\u5c0d\u4e00\u6574\u500b branch \u505a code review \u7559\u8a00\u3002<\/p>\n<p>\u8a3b\uff1a\u4ec0\u9ebc\u662f rebase \u53ef\u4ee5\u53c3\u8003\u820a\u4f5c: <a href=\"\/blog\/archives\/2622\">Git \u7248\u672c\u63a7\u5236\u7cfb\u7d71(3) \u9084\u6c92 push \u524d\u53ef\u4ee5\u505a\u7684\u4e8b<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: 2011\/3\/19 \u53d7\u9080\u6709\u5834\u5206\u4eab Git\u4ecb\u7d39,\u4f7f\u7528\u8207\u958b\u767c\u6d41\u7a0b at Facebook \u8edf\u9ad4\u958b\u767c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ihower.tw\/blog\/5140-git-flow\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Git flow \u958b\u767c\u6d41\u7a0b\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[48],"tags":[],"class_list":["post-5140","post","type-post","status-publish","format-standard","hentry","category-git","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1q6tG-1kU","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/5140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/comments?post=5140"}],"version-history":[{"count":50,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/5140\/revisions"}],"predecessor-version":[{"id":5645,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/posts\/5140\/revisions\/5645"}],"wp:attachment":[{"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/media?parent=5140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/categories?post=5140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ihower.tw\/blog\/wp-json\/wp\/v2\/tags?post=5140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}