git commit --amendã¨git rebase
éå»ã®ã³ããããå¤æ´ããæé ã§å®çª(?)ã®amendã¨rebaseã«ã¤ãã¦ã¡ã¢
ãã ã³ããããæ»ãããã ããªããã£ã¡ã®æé ã§æ»ãã
ç´åã®ã³ããããå¤æ´ãã
ä»ã³ããããããã ãã©ãã¡ãã£ã¨ä¿®æ£è¶³ãã¦ãªãã£ãã£ã¦æ
- ä»ã®ã³ãããããããªæãã§ãã£ã¦
$ git log --oneline 21b391b sixth commit 2d7fb42 fifth commmit 9994b0b fourth commit
- ãã¡ã¤ã«1ã¤å¤æ´ãã¦ã³ãããããªãã
$ echo "I forgot it" >> six.txt $ git add six.txt
- amendã使ã£ã¦ç´åã«ã³ããããå¤æ´ãã
- ã¨ãã£ã¿ãç«ã¡ä¸ããã®ã§ã³ãããã¡ãã»ã¼ã¸ãè¯ããªã«å¤æ´ãã
$ git commit --amend
- diffãè¦ããä¿®æ£ãå ¥ã£ã¦ã¦ãã³ãããã®SHA-1ãå¤ãã£ã¦ã
$ git diff HEAD~ diff --git a/six.txt b/six.txt new file mode 100644 index 0000000..d2c0e78 --- /dev/null +++ b/six.txt @@ -0,0 +1 @@ +I forgot it $ git log --oneline cbe662c sixth commit 2d7fb42 fifth commmit 9994b0b fourth commit
ã³ããããé¡ã£ã¦å¤æ´ãã
ãã¼ã«ã«ã§æ°åã³ããããããã ãã©ããã¼ã¸åã«ã³ããããæ ¼å¥½è¯ããã¦ããããã£ã¦æ
- ãã¼ã«ã«ã§3ã³ãããåä½æ¥ããã¨ãã
]$ git log --oneline --decorate f08317b (HEAD, master) eighth commit a094ddf seventh commit 32a88b4 sixth commit 2d7fb42 (origin/master, origin/HEAD) fifth commmit
- 3ã³ãããã1ã¤ã«çºãããã¨ããã¨
- pickã¯ãã®ã³ãããããã®ã¾ã¾ä½¿ã
- squashã¯ä¸ã¤åã®ã³ãããã¨çºãã¦ãã³ãããã¡ãã»ã¼ã¸ãä»ãç´ã
- fixupã¯ä¸ã¤åã®ã³ãããã¨çºãã¦ãåã®ã³ãããã¡ãã»ã¼ã¸ã使ã
$ git rebase -i HEAD~3 pick 32a88b4 sixth commit squash a094ddf seventh commit #<< squashã«å¤ãã squash f08317b eighth commit #<< ããã
- 確èªããã¨
$ git log --oneline --decorate a65c1ac (HEAD, master) sixth..eighth commits 2d7fb42 (origin/master, origin/HEAD) fifth commmit