问题描述:
今天在git bash中键入 $ git push origin master 进行提交的时候出现出现了 如下错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '/yohayoha/PythonPractice.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
问题原因:
远程库与本地库不一致造成的,在hint中也有提示把远程库同步到本地库就可以了。
解决办法:
使用下面的命令
git pull --rebase origin master
含义
:把远程库中的更新合并
到(pull=fetch+merge)本地库中,–rebase的作用就是取消本地库中刚刚的commint,并把他们接到
更新后的版本库之中。出现如下图执行pull执行成功后,可以成功执行git push origin master
操作。