git-nowããµãã³ãã³ãåãã¦ã¿ã
æè¿ããã¸ã§ã¯ãã®VCSãSubversionããGitã«ç§»è¡ãã¦ããã¯ãã¯é¡ã§git stashãã¾ãã£ã¦ããä»æ¥ãã®é ã§ãããã¿ãªãããããããããã§ãããã?
ãã¦ãããªãå¯ãæå(?)ã®æ¨æ¶ã¯ããã¨ãã¦ãhotfixã¨ãfeatureã®branchä¸ã§git-now使ãã¾ãã£ã¦ãããããªãã§ãã
git-nowã«ã¯--rebaseã£ã¦ãªãã·ã§ã³ããã£ã¦ããã¨ããcommitãããã£ã¡ãããããªãã§ãããããã«ããã«ãªãã·ã§ã³ã¯ããããäºã
ãã£ã¦ãããµãã³ãã³ãåããããªã£ã¦ãã£ã¦ãã¾ãã¾ããï¼ï¼
homebrewåã¨ãããã£ã¡ãã£ãé¢ä¿(è¬)ã§GitHubä¸ã«ããã¦ããã§ãããå
ã
ã®scriptãgistã§GitHubã¨ãã¦forkã§ããªãã¦id:sinsokuãããããã¾ããï¼ï¼
git-nowã£ã¦?
temporaryã®commitãç°¡åã«ã§ããã³ãã³ãã©ã¤ã³ãã¼ã«ã§ãã
詳ããã¯id:sinsokuããã®元ネタãã¿ã¦ãã ããã
ãµãã³ãã³ãã«ã¤ãã¦
ãã¾ã®ã¨ããrebaseã¨grepã¨ãããµãã³ãã³ããããã¾ãã
rebase
rebaseã¯å
ã
ã®--rebaseã«ããã¤ããªãã·ã§ã³ãå ããã®ã¨ãå¼æ°ã§branchåãæå®ã§ããããã«ãã¦ã¾ãã
--rebaseã¤ããã¨repositoryä¸ã®å
¨ã¦ã®ã³ãããã¡ãã»ã¼ã¸ããgit-nowãªã³ããããgrepãã¦ãã¡ãããããªãã§ãããèªåçã«ã¯ãã¾ã®branchä¸ã«ããgit-nowã³ãããã ãrebaseããããã¨ãã»ã¨ãã©ãªã®ã§ãbranchåãä¸ããã¨ããã¾èªåãããbranchã¨æå®ããbranchã¨ã®å
±éã®å
ç¥ããgit-nowã³ããããgrepãã¦ããã¾ãã
$ git now rebase master
git-nowã³ãããã¯temporaryãªãã§æ®éã¯å¾ããä¿®æ£ãããã§ãããééã£ã¦ãã®ã¡ãã»ã¼ã¸ããã®ã¾ã¾pushããã¡ãã£ã¦ãå ´åãªããã¯ã--rebaseãã度ã«å¤ããã³ããããgrepã«å¼ã£ããã£ã¦ãã¡ãããã§ãããã¯ããªãéå®ãã¦ã¾ãï¼ï¼ï½
ãã¨ã¯--push|-pã£ã¦ãªãã·ã§ã³ããã£ã¦rebaseã®ãã¨ã«git pushããã¦ããã¾ãã
æå
ã§testéã£ããgit nowãã¦ãä¸éãæ©è½ãã§ãããgit now rebaseãã¦ã³ã¡ã³ãä¿®æ£å¾ã«remoteã«pushã£ã¦æµããã«ãªãã¨æããã§ããã®è¾ºãç°¡åã«ããããã§ãã
remoteã«ä¸åãpushãã¦ããªãå ´åãgit pushã§ããªããã§ãããããã¨ãã¯--remote|-rãªãã·ã§ã³ã§pushå
ã«æå®ã§ãã¾ããä¸ã§ã¯--set-upstreamããæãã§ããã
$ git now rebase -p master $ git now rebase -p -r origin master
grep
git-nowã³ããããgrepãã¦è¡¨ç¤ºãããµãã³ãã³ãã§ãã
ããã¤ãrebaseã¨åãããã«å¼æ°ã§branchåãæå®ããã¨å
±éå
ç¥ããã®grepã«ãªãã¾ãã
pushããåã«grepãã¦temporaryã³ããããã£ãããª?ã£ã¦æã£ãã¨ãã«ãµã¯ã£ã¨ç¢ºèªã§ãã¡ãããã§ãï¼ï¼
$ git now grep $ git now grep master
ã¤ã³ã¹ãã¼ã«æ¹æ³
GitHubã®READMEã¿ã¦ãããã°åãããã§ãããMacã§homebrewãªäººã¯:
$ brew install https://github.com/iwata/git-now/raw/master/git-now.rb
ãã以å¤ã®äººã¯æ®éã«gitã§ãã£ã¦ãã¦make installã§ããã¾ãã
shell scriptã«ã¤ãã¦
ä»åã¯git-flowã®scriptãåèã«ãã¾ããã
ãã¼ã¹ã¨ãªãé¨åã¯ã³ããã§ãï¼ï¼
getoptã®long-optionã¨Formula
git-flowã®ãã¯ããªã®ã§ãshellã®ã³ãã³ãã©ã¤ã³å¼æ°ã®ãã¼ã¹ã«ã¯shflagsã£ã¦ããã®ã使ã£ã¦ãã¾ãã
helpã¨ãæ¸ãã®ã«ããªã便å©ãªãã§ãããMacã ã¨--pushã¨ãã®long-optionã®ãã¼ã¹ããã¾ãããã¾ããã§ããã
-pã¯ããããã§ããã
-pã§ããã£ã¡ããããã§ããåæã«pushãèµ°ã£ã¡ãããã§ã§ããã°--pushã¨ã¿ã¤ãæ°ãå¤ããªãæ¹ã誤åä½å°ãªãã§ããããããªããã¨æã£ã¦long-optionåããã¼ã®ãã¡ã ãªãâ¦ã¨ãæã£ã¦ã¾ããã
ããã§Googleå
çã§è²ã
調ã¹ã¦ã¿ãã¨shflagsã®BTSã«Failed to parse long option on Mac OSX Snow Leopard with standard getoptã£ã¦ããã®ãçºè¦ï¼ãã¾ããã
ããã§ä¸çªä¸ã®ãã¤ãã¿ãã¨ã
Final comment, for anyone having the same issue on Mac OS X, you can get the enhanced GNU getopt version via MacPorts (http://www.macports.org/).
$ sudo port install getopt
(after you installed MacPorts, see http://www.macports.org/install.php)
getoptã®enhancedãã¼ã¸ã§ã³ãå¿
è¦ã ããMacPortsã§ã¤ã³ã¹ã³ããã°ãããï¼ï¼ï½ã£ã¦æ¸ãã¦ããã¾ãã
ã£ã¦MacPortsãã Σã¾(ãÐãæ±) â¦ãªã®ã§homebrewã§åãã®ã¯ãªãããª?ã£ã¦èª¿ã¹ãã¨ããã¾ãããgnu-getoptã£ã¦ããã®ããããããã§ãã
(ãªã®ã§Formulaã®depends_onã«ã¯gnu-getoptãããã¦ã¾ããä¸å¿ã)
ã¡ãªã¿ã«èªåã®getoptãenhancedãããªããã©ããã¯ä»¥ä¸ãå®è¡ãã¦ã¿ãã°ãããã¾ãã
$ getopt --version
ããã§" --"ã£ã¦è¡¨ç¤ºãããã--versionããã¼ã¹ã§ãã¦ããªãã£ã¦ãã¨ã§æ®éã®getoptã§ãã¼ã¸ã§ã³æ å ±ã表示ããããenhancedã£ã¦ãã¨ã«ãªãã¾ãã
ããã¦æ©éã¤ã³ã¹ãã¼ã«ã
$ brew install gnu-getopt $ getopt --version --
ã£ã¦ãªãã§ããã Σã¾(ãÐãæ±)
enhancedã«ãªããªãï¼ï¼ãwhereãã¦ã¿ãã¨ã
$ where getopt /usr/bin/getopt
ãã? homebrewã§ããããã¤ãããªãããã
gnu-getoptã®Formulaãã¿ã¦ã¿ãã¨"keg_only"ãæå®ããã¦ããï¼
ãªã®ã§ä»¥ä¸ã®ããã«linkãè²¼ãã
$ brew link gnu-getopt $ getopt --version getopt (enhanced) 1.1.4
ï½ï½ï½ï½ï¼ï¼
ããã§--pushãªãã·ã§ã³ã使ããããã«ãªãã¾ããããã®è¾ºã®è²ã
ããããªãã¨ãããªãã®ã§ä¸ã®ã³ãã³ãã§ã¯-pã使ã£ã¦ãã¾ããã§ãééãæãã¨æãã®ã§ã使ããç°å¢ãªã--pushãæã¤ããã«ãã¨ããæ¹ãå®å
¨ã ã¨æãã¾ãã
Formulaã§ã¯
# for longopt depends_on 'gnu-getopt' def install system "make", "prefix=#{prefix}", "install" system "brew ln gnu-getopt" end
ã£ã¦ãã£ã¦ãã¦installã®ä¸ã§ç¡çç¢çlinkããã¦ããã§ãããããã ã¨updateã®ã¨ããã¡ãã¡brew unlinkããªãã¨installã«ã³ã±ãã®ã§ãªããã¤ãã¤ãã§ãã
ãããã®è¾ºãã¾ãã§ããæ¹æ³ãç¥ã£ã¦ãã人ãããã£ããã£ããæãã¦ãã ããï¼ï¼
追è¨
rebaseã®å¾ã«pushã¨ããããã¨ãã¦ãrebase -iãã£ã¡ããã¨shellæãã¡ãã£ã¦è¿ã£ã¦ããªãã§ããï¼ï¼
â¦ã¨ãããã¨ã§--pushã¨ãã®ãªãã·ã§ã³åèãã¾ãµãã
追è¨2
ã¨ããããã--pushã¨ã--removeãªãã·ã§ã³ã¯å»æ¢ã
ãã¨--author|-aãªãã·ã§ã³ã§èªåã®ã³ãããã ããããgrepããããrebaseãããã¨ãã§ããããã«ããã