git rebase -i HEAD~1 #进入交互模式 pick fed40ed foo4 4444 # Rebase 8455d9a..fed40ed onto 8455d9a (1 command) # # 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 # 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. ------------------------------------------------------------------------------ # 修改 pick 为 reword 即保留本次提交,但要对提交信息做编辑 pick fed40ed foo4 4444 # 保存并退出 :wq # 会进入日志编辑模式 foo4 4444 # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Apr 26 18:40:09 2019 +0800 # # interactive rebase in progress; onto 8455d9a # Last command done (1 command done): # reword fed40ed foo4 4444 # No commands remaining. # You are currently editing a commit while rebasing branch 'feat_4' on '8455d9a'. # # Changes to be committed: # modified: foo4 -------------------------------------------------------------------------------- # 修改至你想要的日志 foo4 4444 modify by rebase::reword :wq # 可以看到日志已经被修改 git log --pretty=oneline --abbrev-commit 7ccdb4c (HEAD -> feat_4) foo4 4444 modify by rebase:reword 8455d9a foo4 3333 1548e84 foo4 2222 53e837b foo4 1111