300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 解决办法:git错误 error: failed to push some refs to 'https://github.com/...

解决办法:git错误 error: failed to push some refs to 'https://github.com/...

时间:2023-11-08 09:30:14

相关推荐

解决办法:git错误 error: failed to push some refs to 'https://github.com/...

问题描述:今天在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操作。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。