$ git push origin master
To github.com:xxx/xxx.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:xxx/xxx.git'
hint: Updates were rejected because the remote contains work that you do
hint:not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint:(e.g.,'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards'in'git push --help'for details.
$ git rebase
First, rewinding head to replay your work on top of it...
Applying: add comment
Using index info to reconstruct a base tree...
M hello.py
Falling back to patching base and3-way merge...
Auto-merging hello.py
Applying: add author
Using index info to reconstruct a base tree...
M hello.py
Falling back to patching base and3-way merge...
Auto-merging hello.py
like “squash”, but discard this commit’s log message
x, exec
run command (the rest of the line) using shell
d, drop
remove commit
# 合并最近的3次提交纪录# 之后就会自动进入vi编辑模式
$ git rebase -i HEAD~3
s 7e61ed4 add author info
s 3611cfe add comment info
s f005ed4 add email info
# 最好编辑退出即可# 如果你异常退出了vi窗口,不要紧张,执行下面操作即可
$ git rebase --edit-todo
$ git rebase --continue