git rebase

使用 rebase -i 命令選擇要修改的提交

# 返回 当前head和head~~ 之间的log 前开后闭
git rebase -i HEAD~~

返回以下格式

pick 9a54fd4 添加commit的說明
pick 0d4a808 添加pull的說明

# Rebase 326fc9f..0d4a808 onto d286baa
#
# 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
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#

將第二行的 "pick" 改為 "squash",儲存後並退出。

pick 9a54fd4 添加commit的說明
s 0d4a808 添加pull的說明

:wq

强推 :git push origin 分支名 --force

posted @ 2022-12-20 10:18  Morpheus1024  阅读(14)  评论(0编辑  收藏  举报