å¤ãã³ããããæ¸ãæããï¼ æ´å²ä¿®æ£ä¸»ç¾©è ã®ããã® git rebase -i å ¥é
ç´åã®ã³ããããããç´ãããã¨ãã¯ãgit commit --amend ã使ãã¨å¯è½ã ãããã¦ãããã«æã®ã³ããããããç´ã(æ¸ãæãã)ã¨ãã¯ãgit rebase -i ã使ãã
git rebase -i ã使ãã¨ãå¼æ°ã«ã¨ã£ãã³ããã以éã®ã³ãããç³»åã«å¯¾ãã¦ãã³ãããã®æ¸ãæããåé¤ãçµ±åãè¡ããã¨ãã§ããã
次ã®èª²é¡ãããªããã¨ãç®æ¨ã¨ããªãããgit rebase -i ã®åä½ã追ã£ã¦ãããã
課é¡ãææ°ã®ãã®ããå¤ãã»ãã¸3ã¤åã®ã³ããã(HEAD, HEAD~1, HEAD~2)ã®ãã°ã¡ãã»ã¼ã¸ãæ¸ãæãããã
git rebase -i ã®èµ·å
ã¾ããå¤æ´ãããã³ãããã§ä¸çªå¤ããã®ããä¸ã¤å¤ããã®ãå¼æ°ã«ãã¦ãgit rebase -i ãå®è¡ããããã®å ´å㯠HEAD~3 ã§ããã
$ git rebase -i HEAD~3
ããã¨ãã¨ãã£ã¿ã rebase ã³ãã³ãã¸ã®æ示ãã¡ã¤ã«(æ示票)ãéãã
pick 3agwc04 Add the description of DNS pick d5uu0c2 Rewrite the description of Wake-on-LAN pick 399gee5 Rewrite the description of backup server # Rebase ecd523e..399gee5 onto ecd523e # # Commands: # p, pick = use commit # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. #
ããã§ã¯ãä¸è¨ã®ãã¡ã¤ã«ã®å
é ãã3è¡ã® pick ã edit ã«ãã¦*1ãä¿åã»çµäºãããããã¨ã3agwc04ãd5uu0c2ã399gee5ã®3ã¤ã®ã³ããããããã®é ã«æ¸ãæããä½æ¥ãéå§ãããã
edit ã«ããã³ãããæ¸ãæã
ã¾ãæåã«ãã³ããã 3agwc04 ã«ã¾ã§ç¶æ³ãæ»ã(ææ°ã®ã³ãããã 3agwc04 ã«ãªã)ããªã®ã§ãããã§ããããä½æ¥ãè¡ã£ã¦ãããgit commit --amend ã§ã³ãããã¡ãã»ã¼ã¸ãé©å®æ¸ãæãã¦ãã³ããããç´ã*2ã
åã³ããããçµãã£ããã git rebase --continue ãããããã¨ã次ã®ã³ããã d5uu0c2 ã«ç§»ãã®ã§ã以ä¸åæ§ã«ã³ãããã®æ¸ãæããè¡ã£ã¦ããã
æå¾ã®ã³ããã(ããã§ã¯ 399gee5)ã®æ¸ãæããçµãã£ã¦ãã git rebase --continue ãããã¨ã§ãå ¨ã¦ã®ä½æ¥ãçµäºããã
以ä¸ãã³ãããã®æ¸ãæãã®èª¬æããã¦ãããä½è«ã¨ãã¦ã以ä¸ãã³ãããã®çµ±åã¨åé¤ã«ã¤ãã¦èª¬æããã
ä½è«1ï¼ squash ã«ããã³ãããçµ±å
rebase ã¸ã®æ示票㧠pick ã squash ã«ç´ãã¨ãç´åã®ã³ãããã¨èªã³ããããä¸ã¤ã«ã¾ã¨ããã³ããããä½ããããä¾ãã°ãä¸ã§å¼ç¨ããæ示票ã®3è¡ç®ã® pick ã squash ã«ããã¨ã2è¡ç®ã¨3è¡ç®ã®ã³ããããä¸ã¤ã®ã³ãããã¨ãã¦ã¾ã¨ãããããã¨ã«ãªãã
æ示票ãä¿åã»çµäºããã¨ã2è¡ç®ã¨3è¡ç®ã®äºã¤ã®ã³ãããã®ãã°ã¡ãã»ã¼ã¸ãã¾ã¨ããããã®æ示票ãã¨ãã£ã¿ãéãããããé©å½ã«ç·¨éãã¦ä¿åãçµäºããã°ãã³ãããã®çµ±åã¯å®äºããã
ä½è«2ï¼ ã³ãããã®åé¤
rebase ã¸ã®æ示票ã§ãããã³ãããã®è¡ãåé¤ããã¨ããã®ã³ãããããªãã£ããã¨ã«ã§ãã(åé¤ã§ãã)ãä¾ãã°ãä¸ã§å¼ç¨ããæ示票ã®2è¡ç®ãåé¤ãã¦ä¿åã»çµäºããã¨ãã³ããã d5uu0c2 ã¯ãªãã£ããã¨ã«ãªãã