Git rebase
查看commit提交日志: Git log
假设有3个commit
log排列(最上面是最近一次的提交):
今天
昨天
前天
合并提交:Git rebase
git rebase -i HEAD~n
这时候会出现vim模式:
pick fe74ddc add sql
pick 84b5a9b code formate
pick 015c496 add sql about user
pick 49fc861 add sql about user
# Rebase c4665dc..49fc861 onto c4665dc (4 commands)
# Note that empty commits are commented out
修改提交日志 squash
除了第一个的不改,剩下的把pick改成squash
pick fe74ddc add sql:user
squash 84b5a9b code formate
squash 015c496 add sql about user
squash 49fc861 add sql about user
# Rebase c4665dc..49fc861 onto c4665dc (4 commands)
# Note that empty commits are commented out
点击 Esc :wq 退出
保存后如果有冲突后,解决冲突。然后 git rebase --continue
更新commit信息
# This is a combination of 4 commits.
# This is the 1st commit message:
add sql:user
# This is the commit message #2:
code formate
# Please enter the commit message for your changes. Lines starting
# No commands remaining.
选择一条commit信息,剩下的全部使用#注释掉
点击 Esc :wq 退出
提交commit
git add .
git push branch
如果push失败: 使用 Git push -f branch