åŸã«ãGitFlowããšåŒã°ããã¡ãœããã説æããèšäºãA Successful Branching Model for Git ãã¯ããããžã§ã¯ãã§Gitã䜿çšããæ¹æ³ã®äºå®äžã®æšæºã«ãªããŸããã Googleã§ã git branching strategy ãã®ãããªãã®ãæ€çŽ¢ããå Žåããã®æ¹æ³ã¯æåã®ãªã³ã¯ã§èª¬æãããŸãïŒã»ãšãã©ã®å Žåã次ã®ãªã³ã¯ã§èª¬æãããŸãïŒã
å人çã«ã¯ãGitFlowãå«ãã§ããéå»æ°å¹Žã«ããã£ãŠãå€ãã®éçºããŒã ã«GitFlowã®äœ¿çšãããããã説åŸããŠããŸããã GitFlowã䜿çšãããšãããŒã ã¯ã³ãŒãå€æŽç®¡çãçµç¹åã§ããŸãããå®è£ ããããšã¯ã§ããŸããã ããããããã¯ïŒå°ãªããšãæ€çŽ¢ãšã³ãžã³ã®çµæã§ã¯ïŒãã®ãããªäžè¬çãªæ¹æ³ã§ãããããååãªçµéšã®ãªãããŒã ããäœããå°ãªããšãäœããã®åœ¢ã§æ©èœããããæ¢ããŠããããŒã ã¯ãã¯ã€ãã¯æ€çŽ¢ã§ãããèŠã€ããããã«ãæåãââãšããåèªãèŠã€ããŸãèšäºã®ã¿ã€ãã«ã«ãã®èª¬æãèšèŒãããŠããŸã-ãŸãã圌ãã¯ãããèããã«äœ¿ãå§ããŸãã ãã®èšäºã§ã¯ãå€ãã®ããŒã ã§å®è£ ããGitãã©ã³ãã䜿çšããããã®ãããã·ã³ãã«ã§å£ããæåããæŠç¥ã説æããããšã§ããã®åäœãã¿ãŒã³ãå°ãªããšããããã«å€æŽããããšæããŸãã å€ãã®å Žåããããã®ããŒã ã¯GitFlowã䜿çšããããšããŸããããThreeFlowãžã®ç§»è¡ãšãšãã«æ¶ããåé¡ãçµéšããŸããã
å³å¯ã«3ã€ã®ãã©ã³ããããããããã®æŠç¥ãThreeFlowãšåŒã³ãŸãã 4ã€ã§ã¯ãããŸããã 2ã€ã§ã¯ãããŸããã äžã
ãŸãããã ã®èŠåïŒç¹å¹è¬ã¯ãªããThreeFlowãäžèœè¬ã§ã¯ãããŸããã åžžã«é©åãšã¯éããŸããã çµã¿èŸŒã¿éçºããªãŒãã³ãœãŒã¹ãããžã§ã¯ãã§ã¯ããŸãæ©èœããªããšæããŸãã ãããããããžã§ã¯ãããŒã å šäœã1ã€ã®äŒç€Ÿã§åããŠãããå€éšéçºè ããã®ããŒã«èŠæ±ããªãç¶æ³ã§ã¯éåžžã«æåããŸãã ããªãã¡ ããŒã ã®å šå¡ãã³ãŒãã«å®å šã«ã¢ã¯ã»ã¹ã§ãããªããžããªã«æžã蟌ãããã«å¿ èŠãªãã¹ãŠã®æš©éãæã£ãŠããŸãã
ããã§ã¯ãGitFlowã®äœãåé¡ã«ãªã£ãŠããŸããïŒ
èŠããã«ãGitFlowã®äœãåé¡ãªã®ãã¯ãéçºäžã®æ©èœããšã«ãã©ã³ããäœæãããšãã圌ã®ã¢ã€ãã¢ã§ãã æ©èœã®ãã©ã³ãã¯æªã®æ ¹æºã§ãã ãããã®ãã©ã³ããæäŸãããã®ã¯ãã¹ãŠãåé¡ãåé¡ããããŠåã³åé¡ã§ãã ãã®èšäºããæçšãªãã®ããŸã£ããåŸãããªãå ŽåããŸãã¯ããã§èªãã®ããããå Žåã¯ãæ©èœãã©ã³ããã²ã©ããšããèããèŠããŠãããŠãã ããã
å ¬å¹³ãæãããã«ãå ã®èšäºã§ã¯æ©èœã®ãã©ã³ãã«ã€ããŠèª¬æããŠããããšã«æ³šæããŠãã ããããããã¯ãéåžžãåã ã®éçºè ã®ãã·ã³ã«ã®ã¿ååšããã¡ã€ã³ãªããžããªïŒãªãªãžã³ïŒã«ã¯ååšããŸãããã ããããåãèšäºã§ãGitFlowã説æããå³ã¯ãããç°ãªã£ãŠç€ºããŠããŸãã æ©èœãã©ã³ãã«ã¯ãèµ·æºãããããŸãã ããã«ãå€ãã®éçºããŒã ãGitFlowã䜿çšããŠããããšã確èªããŸããããå¥ã ã®éçºãã·ã³ã§ã®ã¿ãã©ã³ãã䜿çšãããšããèè ã®æšå¥šã«æ³šæãæã£ãŠããŸããã§ããã ç§ãèŠããã¹ãŠã®äººã¯ãèµ·æºã«ååšããé·æçãªããŒã«ãšããŠæ©èœãã©ã³ãã䜿çšããŸããã
äžè¬çã«ããã·ã³ã®æ©èœã®ãã©ã³ããäœæããŠãåé¡ã¯ãããŸããã ããã¯ããããžã§ã¯ãã§è€æ°ã®ã¿ã¹ã¯ãåæã«åŠçããå¿ èŠãããå Žåã«ã¿ã¹ã¯ãåãæ¿ããã®ã«é©ããæ¹æ³ã§ãã ããã¯ããã¹ãŠã®äœæ¥ããªã¢ãŒããªããžããªãšåæãããããšãªãå°ããªä¿®æ£ãè¡ãå¿ èŠãããå Žåã«ããã¹ã¿ãŒãã©ã³ããã¯ãªãŒã³ã«ä¿ã€ããã®è¯ãæ¹æ³ã§ãã ããããå ã®GitFlowã®æšå¥šãè¶ ããŠãå ã®æ©èœãã©ã³ãã®äœæãå³ããçŠæ¢ããŸãã
åã ã®æ©èœã«é·ãååšãããã©ã³ãã䜿çšããå Žåããããã®çµ±åã®å°çã¯ããªãã®çµ¶ãéãªãçŸå®ã«ãªããŸã ã 2人ã®ãšã³ãžãã¢ãããããç¬èªã®æ©èœã§ãããããç¬èªã®ãã©ã³ãã§æ£åžžã«äœæ¥ãè¡ã£ãŠããŸããããã©ãã«ãåŒãèµ·ãããã®ã¯äœããããŸããã ããããã©ã¡ããäžæ¹ãä»æ¹ã®äœæ¥ãèŠãããšã¯ãããŸããã ãã©ã³ããã¡ã€ã³ã®éçºãã©ã³ããšå®æçã«åæããŠããå Žåã§ããæ¢ã«å®äºããŠæè²ãããæ©èœã®ã³ãããã®ã¿ã衚瀺ãããäºãã®çŸåšã®äœæ¥ã¯è¡šç€ºãããŸããã ãããŠãéçºè Aã¯èªåã®æ©èœã®éçºãçµäºããã¡ã€ã³ãã©ã³ãã«ã³ãŒããæ³šå ¥ããŸãã éçºè Bã¯ãããã®å€æŽãããã¯ã¢ãããããæåŸã«ç«¶åãã人ã¯èª°ã§ãããŸããªãããšããå€å žçãªåé¡ãååŸããŸãã 圌ã¯ã»ãã®1åéé ããŠãããããããŸããããããã§åœŒã¯ããã§éçºè Aãæžãããã®ãšãããããã¹ãŠé ãããæ¹æ³ãç解ããããšããŠäœæéãè²»ãããŸãã ãããŠããã®ãåé¢ããããéçºãå¥ã ã®æ©èœãã©ã³ãã§å®è¡ãããæéãé·ããªãã°ãªãã»ã©ãããŒãžã«äŒŽãçã¿ãšèŠãã¿ã¯å€§ãããªããŸãã
æ©èœã®æ¢åã®ãã©ã³ãã¯ãäœæ¥ãåçŽåãããã®ã§ã¯ãããŸããã åŸã§åé¡ãå éãããã ãã§ãã éçºè éã®ã³ãã¥ãã±ãŒã·ã§ã³ã®äž»ãªåœ¢åŒã¯ããœãŒã¹ã³ãŒãã§ãã å®æçãªç«ã¡äžããäŒè°ã®èšç»ãå顧ãªã©ã§å¥œããªã ãèªåãæ °ããããšãã§ããŸãããããã¯éèŠã§ã¯ãããŸããã ãªãŒã±ã¹ãã©ã®ãªããŒãµã«ãæ³åããŠã¿ãŠãã ããããã¥ãŒãžã·ã£ã³ã¯é·ãéãã©ã®ããã«æ²ãæŒå¥ãããã話ãåããŸããããã®åŸãææ®è ã¯éšå±ã«åæ£ããŠããããã®ããŒãããªããŒãµã«ããããäŸé ŒããŸãã ãã®ãããªãªããŒãµã«ã«ã¯æå³ããããŸããïŒ ãããã£ãŠããœãããŠã§ã¢éçºã«äŒŽããŸããæ©èœãã©ã³ãã§ã®äœæ¥ã¯ãæ¬è³ªçã«éçºè éã®ã³ãã¥ãã±ãŒã·ã§ã³ã«ãããèŽåœçãªæ²é»ã«é¡äŒŒããŠããŸãã æ©èœã®ãã©ã³ãã¯ã²ã©ãã§ãã
ããã«ãæ©èœãã©ã³ãã¯éåžžã«ã¹ã±ãŒã©ãã«ã§ãã èªåã®å¿«é©ãã®ããã«æ©èœãã©ã³ããäœæããéçºè ã¯åé¡ã§ã¯ãããŸããã ããããããªãã®ããŒã ã¯æé·ããŠãããåéçºè ã¯æŽ»çºã«éçºããŠããæ©èœããšã«ãã©ã³ããæã£ãŠããŸãã ããã§ãšãããããŸããããªãã¯ä»ããã©ã³ãã®åãã¢ã«åé¡ãæ±ããŠããŸãã ããã°ã©ããŒã8人ã ãã«ããŠãããããããã©ã³ãã®1ã€ã®æ©èœã ãã§åäœããããã«ããŸãã ãããŠä»ãããªãã¯28ïŒãã¢ã®æ°ïŒã®å£ããéä¿¡åç·ãæã£ãŠããŸãã éçºè ããã1人ããã©ã³ãã1ã€è¿œå ããŸãããçŸåšã36ã®ãåŽãããããŸãã
ãã©ã°ã䜿çšããŠæ©èœãæå¹ã«ãã
ãã©ã³ãã䜿çšããŠæ©èœãéçºãã代ããã«ã ãã©ã°ã䜿çšããŠæ©èœããªã³ãŸãã¯ãªãã«ããŠã¿ãŠãã ããã ç°¡åã§ãã ããŒã«ãã©ã°ã宣èšããããšã«ãããæ°ããæ©èœã®éçºãéå§ããŸããããã«å¿ããŠããããå«ãŸããŸãã ããã©ã«ãã§falseã«èšå®ããŸãããã®å Žåãæ°ããæ©èœã®ã³ãŒããªãã§å€ãã³ãŒããåŒã³åºããŸãã
if(newCodeEnabled) { // } else { // }
ãã©ã°èªäœã¯ãã³ãŒãã«ããŒãã³ãŒãã£ã³ã°ããããå€éšæ§æã«è»¢éããããšãã§ããŸãïŒããããConsulãZookeeperã®ãããªãã®ã䜿çšããŸãïŒãããã«ããããã¹ããå®çšŒåã§ãæ°ããæ©èœãæå¹ãŸãã¯ç¡å¹ã«ã§ããŸãã ãããžã§ã¯ããããŒãžã£ãŒãšé¡§å®¢ã¯ãéçºè ãåŒãä»ãããããããžã§ã¯ããçµã¿ç«ãŠçŽãããããå¿ èŠãªããèªåèªèº«ã§ãªã³ãŸãã¯ãªãã«ã§ããæ©èœã®ãªã¹ããåãã補åã³ã³ãããŒã«ããã«ãèŠãããšãéåžžã«å¥œã¿ãŸãã
2人ã®éçºè ãç°ãªãïŒç°ãªãïŒæ©èœã§åãïŒã¡ã€ã³ïŒãã©ã³ãã§äœæ¥ããå Žåãããããã®ãã©ã°ãäœæããŸãã ãããŠã圌ãã¯å®æçã«ã³ãŒããã³ãããããã ãã§ãã ãã®å Žåã®ç«¶åã®å¯èœæ§ã¯æå°éã§ãã 誰ã§ãé©åãšå€æããã³ãŒããã³ãããã§ããŸãã 誰ããèªåã®ããŒã«ã«ãªããžããªãã¡ã€ã³ãªããžããªãšåæã§ããŸã-éåæã¯æå°éã«æããããŸãïŒç¢ºãã«1å¶æ¥æ¥ä»¥å ïŒã 競åã¯ãŸã£ãããªãããæå°éã«æããããŸãã GitFlowãæäŸããããã«ãæ°æ¥ãŸãã¯æ°é±éã§ã°ããŒãã«ãªå€æŽãè¡ãããããéå»1æéã§ãã®10è¡ã§ååãäœãå€æŽããããç解ããæ¹ãã¯ããã«ç°¡åã§ãã
ãããŠãã¯ããããããªããã³ãŒãã®ãã¹ããæžãããïŒãããŠãããªããæžããã®ã§ããïŒïŒããã©ã°ãç¡å¹ã«ããã³ãŒããã©ã³ããšãã©ã°ããªã³ã«ãªã£ãŠãããã©ã³ãã®äž¡æ¹ããã¹ãããå¿ èŠããããŸãã çžäºã«äŸåãã2ã€ã®æ©èœãéçºãããŠããå Žåãéçºæã«ã¯ããã¹ãŠã®çµã¿åããã«å¯ŸããŠ4ã€ã®ãã¹ããå¿ èŠã«ãªããŸãã ããã¯ãéçºãè€éã«ããŠé床ãèœãšãè åšã®ããã«èãããŸãããæ°æ©èœã®éçºåŸã«ãå€ããã³ãŒããããã¯ïŒããã³ãããã®ãã¹ãïŒãåé€ãããããšãå¿ããªãã§ãã ãããããããã°ã幟äœåŠçãªè€éããå¢ããŸããã
æ°æ©èœã®ãã©ã°ãããåçã«äœ¿çšã§ããŸãã ããŒã¿ãã¹ããŸãã¯A / Bãã¹ãã®ããã«ãããããç¹å®ã®ãŠãŒã¶ãŒã°ã«ãŒãã«ãªã³ã¯ã§ããŸãã
æ©èœã®éçºãå®äºããæ¬çªç°å¢ã§ããã©ã«ãã§æå¹ã«ãªã£ãããå€ãã³ãŒããšãã©ã°èªäœãåé€ããããã«ãåªå 床ã®äœãå°ããªã¿ã¹ã¯ãã¹ã±ãžã¥ãŒã«ã§ããŸãã ãŸãã¯ãäœããã®çç±ã§æ©èœãç¡å¹ã«ãããå ŽåïŒæ°ããã³ãŒãã®å®å®æ§ã®åé¡ãããã¯ãšã³ãã®è² è·èª¿æŽïŒããããè¡ãããšã¯ã§ããŸããã ãããã«ããããã©ã°ãšå€ãã³ãŒããåé€ãŸãã¯æ®ãããšãæèçã«æ±ºå®ããããšãéèŠã§ã-ãããå¿ãããšãã³ãŒãã¯ãããŠéçºè ã®æ°ãæ£ããã ãã§å®éã®å©çããããããªãå€ãæªäœ¿çšã®æ©èœã®ã³ã±ã«æé·ããŸã
æ°ããæ©èœãçµã¿èŸŒãããã®ãã©ã°ã¢ãããŒãã®äŸ¡å€ã¯ãéå°è©äŸ¡ãããŠããŸãã æ©èœã®ãã©ã³ãã§ã¯ãªãæ©èœã®ãã©ã°ã䜿çšãå§ãããšããã«ãæ»ããããªãããšãä¿èšŒããŸãã ç§ã®èšæ¶ã§ã¯ãã»ãšãã©ã®å Žåãé ããæ©ããç¬ç«ããé·å¯¿åœãã©ã³ãã§ã®å€§ããªæ°æ©èœã®éçºã¯ãäœäººãã®ããã°ã©ããŒã®æ³šæãšGitã®æ·±ãç¥èãå¿ èŠãšããåé¡ã«ã€ãªãããŸããã åæã«ãåããã©ã³ãã§äœæ¥ããæ°ããæ©èœã®ãã©ã°ãç«ãŠããšããã¢ãããŒãã§ã¯ã1人ã§æ°åã§è§£æ±ºã§ããªãã£ã競åã¯çºçããŸããã§ããã
ã ããThreeFlow
ããã§ãæ©èœã®ãã©ã³ããæªãçç±ãšããããã眮ãæããããšãã§ãããã®ãèŠã€ããŸããã ããããThreeFlowåå²ã¢ãã«èªäœã«ã€ããŠèª¬æã§ããŸãã
ãã®ã¢ãããŒãã§ã¯ããã¹ãŠã®éçºè ã1ã€ã®ãã¹ã¿ãŒãã©ã³ãã§äœæ¥ããŸãã æ©èœãç°¡åãªå Žåã1åã®ã³ãããã§å®è£ ããã³è¿œå ãããã ãã§ãã æ©èœã®éçºã«æéããããå Žåã¯ãæåã«ãã©ã°ïŒããã©ã«ãã§ã¯ç¡å¹ïŒãè¿œå ãããŠã¢ã¯ãã£ãã«ãªããŸãã éçºè ã¯ãã®ãã©ã°ãããŒã«ã«ã§æå¹ã«ããŠæ°ããæ©èœãéçºããã³ãã¹ãããŸãããã¡ã€ã³ãªããžããªã®ã³ãŒãã¯äŸç¶ãšããŠãå€ããã³ãŒããã©ã³ãã䜿çšããŸãã ã³ãããããã¹ã¿ãŒã«è¿œå ããã«ã¯ããªããŒã¹ã䜿çšãããŸãã ããŒã«ã«ãã©ã³ãã䜿çšããŠæ©èœãæäœããå Žåããã¹ã¿ãŒã«ç§»åããå¿ èŠããããŸãããã®ãããå ã ãã®ãã©ã³ãã®çè·¡ã¯ãããŸããã
以äžã§ãã ãããŠãéçºããã»ã¹å šäœãè¡ãããŸãã 1ã€ã®ãã©ã³ãããã¹ã¿ãŒã ãã®äžã®ãã¹ãŠã®ã³ãŒãã å¿ èŠãªãã®ã¯ãã¹ãŠãã©ã°ã§ãªã³ãŸãã¯ãªãã«ãªããŸãã ãã¹ãŠã®éçºè ã¯åãã³ãŒããæã¡ãå€ãã®å Žåäºãã«åæããŠããŸãã ThreeFlowã®ä»ã®ãã¹ãŠã¯ãéçºã§ã¯ãªããªãªãŒã¹æŠç¥ã«é¢ãããã®ã§ãã
ãªãªãŒã¹
ãªãªãŒã¹æå»ãæ¥ããšïŒã¹ã±ãžã¥ãŒã«ã©ããããŸãã¯ããã¥ã¢ã«ã«èšèŒãããŠããå ŽåïŒããã¹ã¿ãŒãã©ã³ãã®ãã¹ã©ã€ã¹ãããªãªãŒã¹åè£ãã©ã³ãã«ãªããŸãã åããã©ã³ãããã¹ãŠã®ãªãªãŒã¹åè£ã«äœ¿çšãããŸãã
ãã®ãã©ã³ãã®ç®çã¯ããªã°ã¬ãã·ã§ã³ïŒããã³ãã®ä»ã®ïŒãã¹ããå®è¡ããããã«QAããŒã ãåãåããã«ããæäŸããããšã§ãã çè«çã«ã¯ããã®ãªãªãŒã¹åè£ã®æ°æ©èœã¯ãéçºãšçµã¿èŸŒã¿ã®éçšã§ãã§ã«QAã«ãã£ãŠãã¹ããããŠããŸãããããããQAã¯ãªãªãŒã¹åè£ã§ããããå確èªããããšæãã§ãããã
ãªãªãŒã¹åè£ãäœæããã«ã¯ã次ã®ããã«ããŸãã
$ git checkout candidate # , candidate origin/candidate $ git pull # , $ git merge --no-ff origin/master $ git tag candidate-3.2.645 $ git push --follow-tags
ããã§--no-ffãã©ã°ã䜿çšããçç±ã¯ãããŒãžã³ãããïŒ2ã€ã®èŠªãæã€æ°ããã³ãããïŒãäœæããããã§ãã 圌ã®äž¡èŠªã®1人ã¯ãªãªãŒã¹åè£ãã©ã³ãã®åã®HEADã§ããã2çªç®ã¯ãã¹ã¿ãŒãã©ã³ãã®HEADã§ãã ããã«ããã誰ããã€ãªãªãŒã¹åè£ãäœæããããäœãæ£ç¢ºã«äœã«ãªã£ãã®ãïŒmasterãã©ã³ãã®ã³ãããïŒã®å±¥æŽãç°¡åã«è¿œè·¡ã§ããŸãã
ãŸãããªãªãŒã¹åè£ã®ã¿ã°ãäœæããããšã«ãæ°ã¥ããããããŸããã ããã«ã€ããŠããå°ãã
ãªãªãŒã¹åè£ã®ãã¹ãäžã«ãã°ãæ€åºãããå Žåããããã¯ãªãªãŒã¹åè£ãã©ã³ãã§ä¿®æ£ãããããã§æ°ãããªãªãŒã¹åè£ãããŒã¯ãããä¿®æ£ãããå€æŽããã¹ã¿ãŒã«ã¹ããŒã«ãããŸãã ãŸãããã©ã³ãéã§ã©ã®ã³ãŒãã移åãããããæ£ç¢ºã«è¡šç€ºããããããããã®å€æŽã¯ã--no-ffããã©ã¡ãŒã¿ãŒã§é©çšããå¿ èŠããããŸãã
ãªãªãŒã¹åè£ããã¹ãããã³æ¿èªããããšããã®HEADãHEADãªãªãŒã¹åè£ãã©ã³ããæãããã«ãªãªãŒã¹ãã©ã³ããæŽæ°ããŸãã ãªãªãŒã¹åè£ããšã«ã¿ã°ãããããããªãªãŒã¹ãã©ã³ãã«ããã·ã¥ããã ãã§ãã
$ git push --force origin candidate-3.2.647:release
ããã§ã®ã--forceããã©ã¡ãŒã¿ãŒã¯ããªãªãŒã¹ãã©ã³ãã®ãã¹ãŠã®å€æŽãç¡èŠããHEADãåãã³ãããã«åŒ·å¶ããããšãæå³ããŸããããã¯ããªãªãŒã¹åè£ã®æåŸã«äœæãããã¿ã°ã瀺ããŸãïŒäžèšã®äŸã§ã¯candidate-3.2.647ïŒã ããã¯ããŒãžã§ã¯ãããŸããããããã¯ããã§ã¯å¿ èŠãªãããã§ãã Gitã®è©±ãè€éã«ãããã¯ãããŸãããäžè¬ã«ããªãªãŒã¹ãã©ã³ããäœæããå¯äžã®çç±ã¯ãå®çšŒåç°å¢ã§èŠã€ãã£ãé倧ãªåé¡ã«å¯Ÿããç·æ¥ä¿®æ£ã®çè«çãªå¿ èŠæ§ã§ãã ã¯ãããã®ã--forceãã¯ãªãªãŒã¹ãã©ã³ãã®ãã¹ãŠã®ããããã£ãã¯ã¹ãæ¶å»ããŸãã ãã ããæ°ããæ©èœãåãã補åã®æ¬¡ã®ããŒãžã§ã³ãåæã«ãªãªãŒã¹ããããŒã ã®å¥ã®ã¡ã³ããŒãæ¬çªç°å¢ã®ãã°ãä¿®æ£ãããšããããžã§ã¯ã管çãšã³ãã¥ãã±ãŒã·ã§ã³ã«é倧ãªåé¡ãçããŸãã ãããã¯ããã©ã³ãããªãªãŒã¹ãäžå¿ãšããããããã¹ãŠã®ãã³ã¹ã®éå§åã§ãã£ãŠã解決ããå¿ èŠããããŸãã ãªãªãŒã¹ãã©ã³ãã§ã®ä¿®æ£ã¯éåžžã«ãŸãã§ãããåœç¶ããªãªãŒã¹åè£ãšãã¹ã¿ãŒãã©ã³ãã§åæ¢ããå¿ èŠããããŸãã
ããŒãžã®ä»£ããã«--forceã䜿çšããçç±ã¯ãHEADãªãªãŒã¹åè£ãã©ã³ãã®ããŒãžã³ããããšHEADãªãªãŒã¹ãã©ã³ãã®ã³ããããç°ãªãsha-1ãæã€å¯èœæ§ãããããã§ããããã¯å¿ èŠãªãã®ã§ã¯ãããŸããã ãªãªãŒã¹ã§æ°ããã³ããããäœæããã®ã§ã¯ãªãããªãªãŒã¹åè£è ã«ãã£ãŠéžæãããæ£ç¢ºãªã³ãããããªãªãŒã¹ãšåŒã³ãŸããããã¯ãQAããŒã ã«ãã£ãŠãã¹ãããããã®è²¬ä»»è ã«ãã£ãŠãªãªãŒã¹ãæ¿èªãããŸããã ããããŸãã«ã--forceãã®æ©èœã§ãã
ãããã®æšå¥šäºé ã«åŸãã°ãgitãªããžããªã®ã¹ããŒãªãŒã¯äžã®å³ãšéåžžã«ãã䌌ããã®ã«ãªãããã©ã³ãéã§ç§»åããã³ããããæ£ç¢ºã«ç€ºããŸãã
ãªãªãŒã¹ããŒã
æ°ãããªãªãŒã¹ã®ããªãªãŒã¹ããŒãããç°¡åã«çæã§ããŸãã å¿ èŠãªã®ã¯ãæåŸã®ãªãªãŒã¹ã¿ã°ãšçŸåšã®ãªãªãŒã¹åè£ã¿ã°ã®éããååŸããããšã ãã§ãã ãªãªãŒã¹ãã©ã³ãã«ã¯ããã€ãŠãªãªãŒã¹åè£ã ã£ããã®ããããŸãã®ã§ãã©ããèŠã€ããããšãã§ããŸãïŒ
$ git describe --tags release candidate-3.1.248
ãªãªãŒã¹åè£ã«åè£-3.2.259ãããããšãããã£ãã®ã§ã次ã®2ã€ã®ã¿ã°ã®éããååŸã§ããŸãã
$ git log --oneline candidate-3.1.248..candidate-3.2.259
ããŠããŸãã¯ã¿ã°ããªããŠãããªãªãŒã¹ã®HEADãšåè£ãã©ã³ããæ¯èŒããã ãã§ãïŒ
$ git log --oneline release..candidate
該åœããæäœ
ThreeFlowã§äœæ¥ãããšãã«äžè¬çã«äœ¿çšãããæäœã次ã«ç€ºããŸãã ãã¹ãŠã®äŸã¯ãããŒã«ã«ãã©ã³ãããªã¢ãŒããã©ã³ãã«æ£ããé¢é£ä»ããããŠãããçŸåšã®å€æŽãå«ãŸããŠããããšãåæãšããŠããŸãã ããã«ã€ããŠããããããªãå Žåã¯ãããäžåºŠgit fetchãå®è¡ããmasterã ãã§ãªãorigin / masterãªã©ã®ååã䜿çšããããšããå§ãããŸã
masterãã©ã³ããããªãªãŒã¹åè£ãäœæããã«ã¯ã©ãããã°ããã§ããïŒ
$ git checkout candidate $ git pull $ git merge --no-ff master $ git tag candidate-3.2.645 #optionally tag the candidate $ git push --follow-tags
ãªãªãŒã¹åè£ãããªãªãŒã¹ããã«ã¯ã©ãããã°ããã§ããïŒ
$ git push --force origin <tag for the candidate>:release
äœããã®çç±ã§ãªãªãŒã¹åè£ã«ã¿ã°ãä»ããªãããšã«ããå Žåã次ã®ããšãè¡ãå¿ èŠããããŸãã
$ git push --force origin candidate:release
ç¹å®ã®ã³ããããæã€ãã©ã³ããèŠã€ããã«ã¯ã©ãããã°ããã§ããïŒ
ç¹å®ã®å€æŽããªãªãŒã¹åè£ãŸãã¯ãªãªãŒã¹ã«å«ãŸããããšã確èªãããå ŽåããããŸãã 確èªæ¹æ³ã¯æ¬¡ã®ãšããã§ãã
$ git branch -r -contains <sha of commit>
ãã©ã³ãã§HEADãæãã¿ã°ãèŠã€ããã«ã¯ã©ãããã°ããã§ããïŒ
$ git describe --tags <branch>
æ°ãããªãªãŒã¹ã«å«ãŸããã³ããããç¥ãã«ã¯ã©ãããã°ããã§ããïŒ
$ git log --oneline release..<tag of release candidate>
ãŸãã¯ïŒ
$ git log --oneline release..origin/candidate
ãªãªãŒã¹åè£ãšãªãªãŒã¹ãã©ã³ããèšå®ããã«ã¯ã©ãããã°ããã§ããïŒ
ãã¹ãŠã®ãããžã§ã¯ãã¯ãæåã®ã³ãããããå§ãŸããŸãã ããã¯éåžžãreadmeãã¡ã€ã«ãè¿œå ãããããªåçŽãªãã®ã§ãã ãã®ã³ããããããªãªãŒã¹åè£ãšãªãªãŒã¹ãã©ã³ããäœæããããšããå§ãããŸãã ååŸããå¿ èŠãããã®ã¯ã2ã€ã®èŠªãšã®æåã®ããŒãžã³ãããã§ãã ããã«ãããæ£ããã¹ããŒãªãŒãåŸãããŸãã ãã®ãããäžè¬ã«ãmasterãã©ã³ãã®ã³ããããé©åã§ãã æåã®ãã®ãåããŸãããïŒ
$ git branch candidate `git log --format=%H --reverse | head -1` $ git checkout candidate $ git push
ãªãªãŒã¹çšã®ãã©ã³ããäœæããã«ã¯ïŒ
$ git branch release $ git branch release --set-upstream-to=origin/release
ã質å
ããããããã¯ããµããã³ã¢ãã«ãã§ã¯ãããŸãããïŒ
ãã®èšäºã§èª¬æãããŠããåå²æŠç¥ã¯ãJussi Judinã«ãã£ãŠèª¬æããããGactFlowã®ä»£æ¿ãšããŠããŸããã¹ãŠã®äœæ¥ã«masterãã©ã³ãã䜿çšãããã ãµããã³ã¢ãã« ãã«éåžžã«äŒŒãŠãããšæããããããããŸããã ã¯ãã倧éšåã¯ããã§ãã äž»ãªéãã¯ãJudinãã³ããããmasterãã©ã³ãããreleaseãã©ã³ãã«éžæçã«ç§»åããããšãææ¡ããŠããããšã§ãïŒããã§ãªãŒããã¯ãïŒã ç§ã¯ããã«æåºãšããŠå察ããŠããŸãã ã³ãããã®éžæçãªç§»åã¯ããã¹ã¿ãŒã®ããã€ãã®çµ¶å¯Ÿã«å£æ» çãªç¶æ ãšç·æ¥ãªãªãŒã¹ã®å€§ããªå¿ èŠæ§ã§æåŸã«äœ¿çšãããã¹ã極端ãªæ段ã§ãã ããŒãžããããªããŒã¹ã䜿çšããããšã奜ã¿ãŸãã ãããŠãéžææ§ãé¿ããŸãã
ãã1ã€ã®éãã¯ãThreeFlowã«ãªãªãŒã¹åè£ã®ãã©ã³ããååšããããšã§ããããã¯ãå¿ èŠæå°éã®æªãšããŠåãå ¥ããŠããŸãã å人çã«ãç§ã®ç®æšã¯ãåã³ãããã§æãçªããŠããã«éçšã«ç§»ãããããªç¶æ ã«masterãã©ã³ããç¶æããããšã§ãã ããããå€ãã®ããŒã ã«ãšã£ãŠããã®ã¢ãŒãã§äœæ¥ããã®ã¯é£ãããäžå¿«ã§ããããšã«æ°ä»ããŸããã 人ã ã¯QAããŒã ã®åœ¢ã§ãããã¡ãçšæããéçºè ã«æ¿èªããããã«ãïŒãæªããã®ã§ã¯ãªãããããååŸãããïŒãäžãããã®å質ã«ã€ããŠãã£ãŒãããã¯ããããå¿ èŠããããŸãã ãŸããThreeFlowã¢ãã«ã¯ãã®æ©äŒãæäŸããŸãã 補åã®å質ã«æ éã«é©ããããŒã ã§ã¯ããªãªãŒã¹åè£ãšãªãªãŒã¹ãã©ã³ãã®éãã¯æå°éã«ãªããŸãã
ããããGitFlowã¯æ©èœã®åå²ãªãã§èª¬æãããŠããã ãã§ã¯ãããŸãããïŒ
å®éã以åã«åæ§ã®æ¹æ³ã§GitFlowã䜿çšããŠãã人ã ã«ãã®æŠç¥ã説æããŸããããæ©èœã«ãã©ã³ãã䜿çšããããã¹ãŠã®éçºã¯éçºãã©ã³ãã§è¡ãããããããã¹ã¿ãŒãšåŒã³ããã¹ã¿ãŒãšåŒã°ãããã®ããã©ã³ããšåŒã³ãŸãããªãªãŒã¹ãã ThreeFlowã®äž»ãªã¢ã€ãã¢ã¯ãè€éããæå°éã«æããããšã§ããã GitFlowã¯ãäœããã®çç±ïŒæ©èœããªãªãŒã¹ãããããã£ãã¯ã¹ïŒã§æ°ãããšã³ãã£ãã£ïŒãã©ã³ãïŒã®äœæãæšå¥šããŸãã ãããžã§ã¯ãã倧ãããæéãé·ããªãã°ãªãã»ã©ããã®æŽå²ã¯ã²ã©ãèŠããŸãã ThreeFlowã¯ããã©ã³ãã®æ°ãæå°éã«æããããåªããŠããŸããæ©èœãŸãã¯ããããã£ãã¯ã¹ã®ãã©ã³ãã¯ãããŸããã æ©èœã¯ãŠã£ã¶ãŒãã§èšè¿°ãããä¿®ââæ£ããã°ã©ã ã¯ãªãªãŒã¹åè£ããŸãã¯ãªãªãŒã¹ã«ãé©çšãããŸãã ãŸããå€æ°ã®ãªãªãŒã¹ãã©ã³ãã®ä»£ããã«ãçŸåšã®ãªãªãŒã¹åè£ããã³çŸåšã®ãªãªãŒã¹ãšåŒã°ãããã®ãåžžã«ãããŸãã 3ã€ã®ãã©ã³ãã®ã¿ã åžžã«ã
ãŸãããã©ã³ãããŒãã³ã°ã·ã¹ãã ãäœæããå¿ èŠã¯ãããŸããïŒãã®ãã¡3ã€ãããªããååã¯äžå®ã§ãïŒïŒãã¹ã¿ãŒãåè£ããªãªãŒã¹ã
ãç§ã®ã³ãŒããã©ãã«çœ®ããïŒããšãã質åã«ã¯åžžã«çãããããŸãã ãããçç£äžã®åé¡ã®ããããã£ãã¯ã¹ã§ããå Žå-ãªãªãŒã¹ã ããããªãªãŒã¹åè£ã®ãã°ä¿®æ£ã§ããå Žåãåè£ã«ãããŸãã ãããéåžžã®æ¥åžžæ¥åã®å Žå-ãã¹ã¿ãŒã
ã³ãŒãã¬ãã¥ãŒã¯ã©ãã§ããïŒ
ã¡ã€ã³ã®éçºãã©ã³ãã«å°éããåã«ãã¹ãŠã®ã³ãŒããã¬ãã¥ãŒããã«ãŒã«ãããå Žåã¯ãå¥ã®ãã©ã³ããè¿œå ããã®ãè«ççã§ãïŒéçºãšåŒã³ãŸããã-ã¯ãããã®ååãGitFlowããçãã§ãã ããïŒã ãã®ããããã¹ãŠã®éçºããã®äžã«å ¥ããã¬ãã¥ã¢ãŒã¯æ¿èªãããã³ãããããããããã¹ã¿ãŒã«è»¢éããŸãïŒãŸãããŸãã¯ãã¡ã€ãã©ã€ãºãäŸé ŒããŸãïŒã ãã¡ããã転éããããã®ãšè»¢éãããªãã£ããã®ãäœããã®æ¹æ³ã§è¿œè·¡ããå¿ èŠããããããã¯å°é£ãåŒãèµ·ããå¯èœæ§ããããŸãã ThreeFlowã䜿çšããå Žåãã¡ã€ã³ãã©ã³ãã«ã³ãããããåã«ã³ãŒãã¬ãã¥ãŒã®æŠå¿µãå³å®ããããšã¯ããŒã ã«ãšã£ãŠããŸããããªããããã®ã¢ãããŒãã®ãããªãé©å¿ãå¿ èŠã«ãªãããšãèªããªããã°ãªããŸããã Gerritã®ãããªããŒã«ãåæ§ã®ç®çã§äœ¿çšããŠãã人ããããšèããŸããããç§èªèº«ã¯äœ¿çšããããšããããŸããã
è€æ°ã®ã¢ãŒãã£ãã¡ã¯ããä¿åããã³ãŒãããŒã¹ã¯ã©ãã§ããïŒ
å€ãã®å Žåãã³ãŒãã¯å®éã«ã¯1ã€ã®ã³ãŒãããŒã¹ã«æ ŒçŽãããããããè€æ°ã®ãããžã§ã¯ããçµã¿ç«ãŠãããšãã§ããŸãã ãããã®åã ã®ã¢ã»ã³ããªææç©ã«ã¯ãQAéšéã«ããå¥åã®æ€èšŒãµã€ã¯ã«ãå¿ èŠã§ããããªãªãŒã¹åè£ã®å¥åã®ããŒãžã§ã³ããããŸãã ãã®å ŽåãThreeFlowã¯ã©ã®ããã«æ©èœããŸããïŒ
ããŸããããŸãã ããæè¿ãç§ã¯ãã€ãŠåæ§ã®ãããžã§ã¯ãã§åããŠããŸããã ããã€ãã®ç°ãªãã¢ãŒãã£ãã¡ã¯ããåéããã³ãããã€ãããGitãªããžããªã1ã€ãããŸããã 解決çã¯æããã§ããåã¢ãŒãã£ãã¡ã¯ãã¯ãªããžããªã«2ã€ã®ãã©ã³ããè¿œå ããŸãã ãã¹ã¿ãŒã§ãã¹ãŠã®ã³ãŒããèšè¿°ããç¡å¹åããããã©ã°ã䜿çšããŠæ©èœãæäœããŸãã ãããè¡ãããã«ããªããžããªããåéãããã¢ãŒãã£ãã¡ã¯ãã®æ°ãšæ°ãç¥ãå¿ èŠã¯ãããŸããã ããããããã§ã¯ãªãªãŒã¹ã«ãªããåã¢ãŒãã£ãã¡ã¯ãã«ã¯ããªãªãŒã¹åè£ãšãªãªãŒã¹ã®ããã®ç¬èªã®ãã©ã³ããå¿ èŠã§ãïŒfoo_candidateãfoo_releaseãbar_candidateãbar_releaseã 以äžã§ãã
ããã¯ããªããæã£ãŠãããããåªããŠããŸãã ç§ã®æè¿ã®ãããžã§ã¯ãã®1ã€ã§ã¯ã1ã€ã®å€§ããªã³ãŒãããŒã¹ãã4ã€ã®ç°ãªãã¢ãŒãã£ãã¡ã¯ããåéãããŸããã ããã€ãã®äžè¬çãªã³ãŒãããµããããžã§ã¯ãããšã«åå¥ã®ãã®-ããããŸããã äžæ¹ã§-ãªãªãŒã¹åè£ãšãªãªãŒã¹çšã®8ã€ã®ãã©ã³ããšã1ã€ã®ãã¹ã¿ãŒã ããããäžæ¹ã§ãåã¢ãŒãã£ãã¡ã¯ãã«ã¯ç¬èªã®åå¥ã®ããŒã ããããåã¢ãŒãã£ãã¡ã¯ãã«ã¯3ã€ã®ãã©ã³ãã®ã¿ãé¢é£ããŠããããããããã®ç·æ°ã¯ã»ãšãã©é¢ä¿ãããŸããã§ããã
Gitã³ãã³ããžã®è¿œå ã®åŒæ°ã»ãããã©ãã«ãããŠåé¿ã§ããŸããïŒ
ææ¡ãããã¢ãããŒãã®ç¹åŸŽã®1ã€ã¯ã䜿çšãããã»ãŒãã¹ãŠã®ããŒã ãè¿œå ã®åŒæ°ãæã£ãŠããããšã§ãã ããŒãžãè¡ããã³ã«ãã-no-ffããå¿ããã«è¿œå ããŠãã ããã ãªãªãŒã¹ãäœæããŠã¿ã°ãä»ãããšãã¯ãã¿ã°ãå ã®å Žæã«ä¿åããããã«ããã·ã¥ãããšãã«ã--follow-tagsãã䜿çšããããšããå§ãããŸãã ããã©ã«ãã§ãããã®ã¿ã°ãé©çšã§ããŸãïŒ
$ git config --global merge.ff no
ããã§ãã-no-ffããã©ã¡ãŒã¿ãŒãªãã§mergeã³ãã³ãã䜿çšã§ããŸãïŒæé»çã«è¿œå ãããŸãïŒ
åæ§ã«ãããã·ã¥æã®ã¿ã°ã®å ŽåïŒ
$ git config --global push.followTags true
ãã«æã«èªåãªããŒã¹ãæ§æããããšãã§ããŸãã
$ git config --global branch.master.rebase true
ããŒã«ã«ãã©ã³ãã䜿çšããŠåã ã®æ©èœãæäœããå Žåããã«ãããšãã«ãã¹ãŠã®æ°ãããã©ã³ããèªåçã«ãªããŒã¹ããããšãã§ããŸãïŒ
$ git config --global branch.autosetuprebase always
ãããã®ã«ãŒã«ãçŸåšã®ãªããžããªã®ã¿ã«é©çšããå šå¡ã«ã¯é©çšããªãå Žåã¯ãäžèšã®ã³ãã³ãããã--globalãããŒãåé€ããããšãã§ããŸãã
ãªãªãŒã¹ãã©ã³ãã«ããŒãžã䜿çšã§ããŸããïŒ
ãŸãããŸã第äžã«ãããªãã¯èªç±ãªäººã§ãããããªãã¯äœã§ããããããšãã§ããŸãã ç§ãšä»ã®äžéšã®äººã«ãšã£ãŠããŸãæ©èœããæŠç¥ã説æããŠããŸãã ç§ã«ã¯ãGitFlowãããåªããŠããããã§ãïŒåçŽãªããïŒã
第äºã«ãã¯ãã-forceããŒãæŒããŠå±¥æŽæ å ±ã®äžéšã倱ããšããèããæ°ã«å ¥ããªãå Žåã¯ã-no-ffããŒãšããŒãžã§ããŸãã ããã§ã®ãã©ã¹ã¯ããã©ã³ãéã§ã³ãããã転éããããŸããŸãªæ¹æ³ãèŠããŠããå¿ èŠããªãããšã§ãã èªåèªèº«ãããŒãžããã ãã§ã--no-ffã¯åžžã«ãããã ãã§ãã
å®éãThreeFlowã®æåã®ããŒãžã§ã³ã§ã¯ããªãªãŒã¹ã®--no-ffãã©ã¡ãŒã¿ãŒãšããŒãžããŠããŸãã«ãã®ãããªåäœã説æããŸããã ããã¯ããŸããããŸãããç©èªã¯ããèªãŸããŸããã ç§ãæ°ã«å ¥ããªãã£ãå¯äžã®ããšã¯ããªãªãŒã¹ãã©ã³ãããã®ãã«ãã¢ãŒãã£ãã¡ã¯ããã以åã¯ãªãªãŒã¹åè£ãšèŠãªãããQAãšãªãªãŒã¹æ¿èªãçµãæ£åŒãªã³ãããã§ã¯ãªãã£ãããšã§ãã ããããšããã¹ãããŠãããå¥ã®ããšãããŠããã®å¥ã®ããšããªãªãŒã¹ããããšãããããŸããã æ®å¿µã ã ãã¡ãããå䜵ãé«é転éã«çœ®ãæããããšãã§ããŸãããããã¯æ å ±ã®æ倱ã«ã€ãªãããæåããããšãä¿èšŒãããŠãããšããäºå®ã§ãããããŸããã
ç§ã®æèŠã§ã¯ãpush + forceã¯ããªãªãŒã¹ã®å 容ãå®éã«ã¯ç¶æ¿ãããã³ãããã®ãã§ãŒã³ã®çšèªã®åå²ã§ã¯ãªãããã®ããã«è§£éãããã¹ãã§ã¯ãªãããšãããæ確ã«ããŸãã ããã¯ãçŸåšå®çšŒåã§åäœããŠããå®éã®ã³ãŒããžã®åãªããã€ã³ã¿ãŒã§ãã ãŸãããªãªãŒã¹ãã©ã³ãèªäœã¯ããã€ãŠæ¬çªç°å¢ã§ã¬ã€ã¢ãŠããããŠããäžé£ã®ã¿ã°ãæããŠããã ãã§ãã ããŠãããã¯çŸåšã®ã³ãŒãã®ãã©ã³ãã§ããããããã€ã§ãããã«æ¬çªçšã®ããããã£ãã¯ã¹ãäœæã§ããŸãã
ãŸãšãããš
äžè²«ããåå²æŠç¥ãªãã§Gitã䜿çšããããšã¯å±éºãªããžãã¹ã§ãã ã ããããããåãïŒ
- ãã¹ã¿ãŒãåè£ããªãªãŒã¹ã®3ã€ã®ãã©ã³ãããããŸã
- ãã¹ã¿ãŒã§åããŠããŸãã ãã¹ãŠã®æ°ããã³ãããã¯ããªããŒã¹ã䜿çšããŠè¿œå ãããŸãã
- éçºããã»ã¹ã®æ©èœã¯ãã©ã°ã«ãã£ãŠç¡å¹ã«ãããŸãã æºåãã§ãããç¹ç¯ããŸãã
- - â master (merge "--no-ff") candidate
- , QA -, ( merge "--no-ff") master
- - , "--forced" release
- release candidate master
以äžã§ãã ThreeFlow Git, .
? ? , "--force" , ? !