Pull Request(PR)ãMerge Request(MR)ãä½ãä¸ã§ãã³ãããå±¥æ´ã¯ã§ããã ã綺éºã«ãã¦ãããããã®ã§ãã
ã¼ãã¯ãã¾ãã³ãããå±¥æ´ã®ç¶ºéºããæ°ã«ããªãæ¹ã§ããã ããã大ããã®PRãMRãã¬ãã¥ã¼ããå´ã«åãã¨ããå¤æ´ã®ã¾ã¨ã¾ããã追ããªãã¨ããªããã®å¤æ´ãããã®ãããé常ã«è¿½ãã«ãããªãã¾ãã ã ããããæè¿ã¯ãã³ãããå±¥æ´ãããªãæèããããã«ãªãã¾ããã
ãã®æã«æ´»èºãã¦ããã®ããã¿ã¤ãã«ã®éãgit commit --fixup
ã¨git rebase --autosquash
ã§ãã
git commit --fixup
git commit --fixup
ã®helpãè¦ãã¨ãå¼æ°ã¨ãã¦commit hashçãåãã
git rebase --autosqush
ã¨çµã¿åããã¦ä½¿ããã®ã§ãããã¨ãèªã¿åãã¾ãã
$ git help commit | grep -A3 '^\s*--fixup' --fixup=<commit> Construct a commit message for use with rebase --autosquash. The commit message will be the subject line from the specified commit with a prefix of "fixup! ". See git-rebase(1) for details.
å®éã«ä½¿ã£ã¦ã¿ã¾ãããã ä¾ãã°ãæ¬ã¨ã³ããªãæ¸ãã¦ããéã®ã³ãããå±¥æ´ããã®ããã«ãªã£ã¦ããã¨ãã¾ãã
$ git log --oneline -2 07d0cf3 (HEAD -> master) add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash` 1312f4d (origin/master, origin/HEAD) add: ä»å å¹´éã¨å½æ°å¹´éåºé
ããã§git commit --fixup
ãå®è¡ããã¨ä»¥ä¸ã®ããã«ãªããã³ãããã¡ãã»ã¼ã¸ããæå®ããã³ãããã®ã¡ãã»ã¼ã¸ã«fixup!
ãã¤ãããã®ãã«ãªãã¾ããã
$ git add -u $ git commit --fixup=07d0cf3 [master a1a197c] fixup! add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash` 1 file changed, 10 insertions(+)
ä½åº¦ãåããã¨ãå®è¡ããå¥ã®ã³ããããéãã¦ã¿ã¾ããã
ããã§ã³ããããã°ãè¦ã¦ã¿ã¾ãããã以ä¸ã®ããã«fixup!
ã®ã³ããããã°ãæ£å¨ãã¦ããç¶æ
ã«ãªãã¾ããã
$ git log --oneline -6 359776e (HEAD -> master) fixup! add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash` f021fcb add: rebaseã®èª¬æ 58c7455 fixup! add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash` 64e68b0 fixup! add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash` a1a197c fixup! add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash` 07d0cf3 add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash`
git rebase --autosquash
ããã§git rebase --autosquash
ãå®è¡ãã¦ã¿ã¾ãã
$ git rebase --autosquash 07d0cf3~ Created autostash: cf1f2ce Current branch master is up to date. Applied autostash.
ã¼ãã¯VS Codeã«GitLens â Git superchargedãå
¥ãã¦ããã®ã§ã以ä¸ã®ãããªã¿ããèµ·åãã¾ããã
æ£å¨ãã¦ããfixup!
ã1ã¤ã«ä¸¦ã³ã容æã«ã³ããããã¾ã¨ãããã¨ãã§ããç¶æ
ã«ãªã£ã¦ãã¾ãã
ãã®ç¶æ ã§rebaseãå®äºãããã¨ã以ä¸ã®ããã«ã¾ã¨ã¾ã£ãã³ããããã°ãä½ããã¨ãã§ãã¾ããã
$ git log --oneline -4 b8b04a3 (HEAD -> master) add: rebaseã®èª¬æ 5323274 add: ã³ãããå±¥æ´ã綺éºã«ããã¨ãã®`git commit --fixup`ã¨`git rebase --autosquash` 1312f4d (origin/master, origin/HEAD) add: ä»å å¹´éã¨å½æ°å¹´éåºé 2f17841 add: ãã¢ããªã¹ãããã¤ã¯ããµã¼ãã¹ã¸ãã®1ç« ã2ç« ãèªãã
ãã®ããã«git commit --fixup
ã¨git rebase --autosquash
ãçµã¿åããããã¨ã§ãã³ããããæ´çãã綺éºãªã³ããããã°ãä½ããã¨ãã§ãã¾ãã
$ git help rebase | grep -A11 '^\s*--autosquash' --autosquash, --no-autosquash When the commit log message begins with "squash! ..." (or "fixup! ..."), and there is already a commit in the todo list that matches the same ..., automatically modify the todo list of rebase -i so that the commit marked for squashing comes right after the commit to be modified, and change the action of the moved commit from pick to squash (or fixup). A commit matches the ... if the commit subject matches, or if the ... refers to the commit's hash. As a fall-back, partial matches of the commit subject work, too. The recommended way to create fixup/squash commits is by using the --fixup/--squash options of git-commit(1).
ãã®ã»ããããã
.gitconfig
ã«ä»¥ä¸ãè¨å®ããã¨æãã®ã§ã¯ãªããã¨ã
rebase.autoSquash
rebase.abbreviateCommands