# Rebase f0ebed6..7933f20 onto f0ebed6 (5 commands) # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # b, break = stop here (continue rebase later with 'git rebase --continue') # d, drop = remove commit # l, label # m, merge [-C | -c ] [ # ] # . create a merge commit using the original merge commit's # . message (or the oneline, if no original merge commit was # . specified). Use -c to reword the commit message. # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out ~
この画面では、コミットに対して何かしらのアクションコマンドを指定することができます。
コミットを編集したい場合は、pickをeまたはeditに変えてあげれば良いです。
なので、以下のようになります。
e c41badb hogeeeeeeeeeeeeee.md追加 pick 0c8384b fuga.md追加 pick 2dddef0 piyo.md追加 pick cfec910 mmm.md追加 pick 7933f20 nnn.md追加 # Rebase f0ebed6..7933f20 onto f0ebed6 (5 commands) # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # b, break = stop here (continue rebase later with 'git rebase --continue') # d, drop = remove commit # l, label = label current HEAD with a name # t, reset = reset HEAD to a label # m, merge [-C | -c ] [ # ] # . create a merge commit using the original merge commit's # . message (or the oneline, if no original merge commit was # . specified). Use -c to reword the commit message. # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out
$ git rebase -i HEAD~5
Stopped at c41badb... hogeeeeeeeeeeeeee.md追加
You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue
基本的には、上記で表示された文言順に改変作業を進めていけばOKです。
該当コミットのコメントを編集する
該当コミットのコメントを編集するには「git commit –amend」を実行します。
$ git commit --amend
実行後、以下のような文言が表示される画面になると思います。
hogeeeeeeeeeeeeee.md追加
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Sat Apr 20 19:11:02 2019 +0900
#
# interactive rebase in progress; onto f0ebed6
# Last command done (1 command done):
# edit c41badb hogeeeeeeeeeeeeee.md追加
# Next commands to do (4 remaining commands):
# pick 0c8384b fuga.md追加
# pick 2dddef0 piyo.md追加
# You are currently editing a commit while rebasing branch 'master' on 'f0ebed6'.
#
# Changes to be committed:
# new file: hoge.md
上部の「hogeeeeeeeeeeeeee.md追加」を変更したいコメントにします。
今回は「hoge.mdに追加」に変更します。
hoge.md追加
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Sat Apr 20 19:11:02 2019 +0900
#
# interactive rebase in progress; onto f0ebed6
# Last command done (1 command done):
# edit c41badb hogeeeeeeeeeeeeee.md追加
# Next commands to do (4 remaining commands):
# pick 0c8384b fuga.md追加
# pick 2dddef0 piyo.md追加
# You are currently editing a commit while rebasing branch 'master' on 'f0ebed6'.
#
# Changes to be committed:
# new file: hoge.md
#
コメント