文章内容
2018/8/15 16:17:47,作 者: 黄兵
push of current branch was rejected remote changes need to be merged before pushing
最近使用PyCharm的时候,由于远程已经更新,但是本地需要提交代码,使用github提示如下问题:
push of current branch was rejected remote changes need to be merged before pushing
出错原因:
是因为远程repository和我本地的repository冲突导致的,而我在创建版本库后,在github的版本库页修改了文件,但是却没有pull到本地。这样就产生了版本冲突的问题。
解决方案:
有三种解决方案:
一、使用强制push的方法:
$ git push -u origin master -f
存在问题:这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。
二、push前先将远程repository修改pull下来
$ git pull origin master $ git push -u origin master
存在问题:本地编写的代码会被覆盖,忙了一天,当天的工作全没了。
三、若不想merge远程和本地修改,可以先创建新的分支:
示意图:
local branch: --- Commit C -- Commit E
/ /
/ /
/ /
origin/branch: Commit A ------ Commit B ---- Commit D $ git branch [name]
然后push:
$ git push -u origin [name]
参考资料:
Cannot push to GitHub - keeps saying need merge
黄兵个人博客原创。
转载请注明出处:黄兵个人博客 - push of current branch was rejected remote changes need to be merged before pushing
如果没有人为操纵,普通人真的能预测股价吗?
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=';
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=';
评论列表