2012/07/05
gitã¨ç¶ç¶ã®é¡ä¼¼æ§ãã¨ããã®ããµã¨èããã
gitã¯å¤æ´ã®ä¾åé¢ä¿ãè¨é²ãã¦ããããã¼ã¸ãèããªããã°ãããã¯ãã©ã³ããèã¨ããæ¨æ§é ã«ãªããä¸æ¹ãç¶ç¶ãããå¦çç³»ã§ã¯ã¹ã¿ãã¯ãæ¨æ§é ã«ãªãããã ãgitã§ã¯ã¹ã¿ãã¯ã®ãããã«ç¸å½ããæä½ (git checkout HEAD^
) ã¯ãã¾ãä¸è¬çã§ã¯ãªããã
call/ccã§ç¶ç¶ãæã¾ããã®ã¯ãgitã®éçºããªã¼ã§ç¾å¨ã®HEADã³ãããIDãè¦ãã¦ãã(ã¿ã°ã§ãã¤ãã¦)ãã¨ã«ç¸å½ãããgit checkout HEAD^
ã§éçºãå·»ãæ»ãã¦ããã³ãããIDããè¦ãã¦ããã°ãã¤ã§ããã®ç¶æ
ã«æ»ã£ã¦ãããã
- ç¾å¨ã®ãã©ã³ãã§call/ccãçºè¡=ç¾å¨ã®ã³ãããBãè¨é²
CALL/CC ---A----B ^SP
- ããã¤ãã¹ã¿ãã¯ãç©ã=ã³ããããã
CALL/CC ---A----B----C----D----E ^SP
- ããã¡ã©call/ccã§ã³ãããEãè¨æ¶
CALL/CC CALL/CC ---A----B----C----D----E ^SP
- æåã®call/ccã§æã¾ããç¶ç¶ãèµ·åãã(大åè±åº) ã¯
git reset --hard B
ã«ç¸å½CALL/CC CALL/CC ---A----B----C----D----E ^SP
call/cc ã使ã£ãã³ã«ã¼ãã³ã¯ãäºã¤ã®ãã©ã³ããè¡ã£ããæ¥ããããæãã
- ä¸ã®ç¶æ
ããå¥ã®å¤æ´ãããã¤ãã³ãããããã
CALL/CC CALL/CC ---A----B----C----D----E \ \ F----G----H ^SP
- ããã§call/ccã§ãã£ã¦Iãè¨é²ãã¦ããã¦â¦
CALL/CC CALL/CC ---A----B----C----D----E \ \ CALL/CC F----G----H ^SP
- Eãè¨æ¶ãã¦ããç¶ç¶ãèµ·å = git checkoutã§ãã©ã³ããä¹ãæã
CALL/CC CALL/CC ---A----B----C----D----E \ ^SP \ CALL/CC F----G----H
- ã³ã«ã¼ãã³ã¯ããããã®æã®æå 端ãã©ã£ãã«è¨é²ãã¦ããã¦è¡ã£ããæ¥ãããããã¨ã§ã ãã©ã³ããåãæ¿ãã¦ä»äºããã®ã«é¡ä¼¼ã
é¨åç¶ç¶ã¯git rebaseã«å°ãä¼¼ã¦ãããããããªãã git resetã¨åºå¥ããããã«ãé¨åç¶ç¶ã®shift/resetã 大æåã§SHIFT/RESETã¨æ¸ããã¨ã«ããã
- ã¹ã¿ãã¯ãæ·±ããªã£ã¦ããéä¸ã§RESETãSHIFTãçºè¡ããã¨ããã
RESET SHIFT ---A----B----C----D----E ^SP
- SHIFTé¨åã®å®è¡ãçµããã¨ãã¹ã¿ãã¯ã¯èªåçã«resetã¾ã§å·»ãæ»ãããã
git reset --hard B
ããã¨æãã°ãããRESET SHIFT ---A----B----C----D----E ^SP
- ãããããã²ã¨ã¤popããã¨ããã (
git checkout HEAD^
)RESET SHIFT ---A----B----C----D----E ^SP
- æ°ããªå¤æ´ãå ãã¦commitãã¦ãã
RESET SHIFT ---A----B----C----D----E \ \ F----G ^SP
- éä¸ã§RESETããã¨ããã
RESET SHIFT ---A----B----C----D----E \ \ RESET F----G----H----I ^SP
- ãã®æç¹ã§ãã£ãã®SHIFTã§æã¾ããé¨åç¶ç¶ãèµ·åãããã¨ã¯ã
git rebase --onto G B E
ã«ç¸å½ãããRESET SHIFT ---A----B----C----D----E \ \ RESET F----G----C'---D'---E' ^SP
ã¨ããã¾ã§èãããã ãã©ããã¼ã¸ã¨ãèãåºãã¨ã¢ããã¸ã¼ãç ´ç¶»ããã®ã§ ãã£ã±ãç¡çãããæ°ããã¦æ¾ãæãããªãã¯ç¡ãã
Tags: ç¶ç¶, git, Programming
Post a comment