您的位置:首页 > 其它

git 添加远程仓库后无法push

2017-08-30 16:35 162 查看
push的时候提示fatal:refusingtomergeunrelatedhistories

假如我们的源是origin,分支是master,那么我们需要这样写
gitpulloriginmaster----allow-unrelated-histories



提示:
hint:Updateswererejectedbecausethetipofyourcurrentbranchisbehind
hint:itsremotecounterpart.Mergetheremotechanges(e.g.'gitpull')

hint:beforepushingagain.

hint:Seethe'Noteaboutfast-forwards'in'gitpush--help'for
details.


远程repository和我本地的repository冲突导致的,而我在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。

有如下几种解决方法:

1.使用强制push的方法:

$gitpush-uoriginmaster-f

这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

2.push前先将远程repository修改pull下来

$gitpulloriginmaster

$gitpush-uoriginmaster

3.若不想merge远程和本地修改,可以先创建新的分支:

$gitbranch[name]

然后push

$gitpush-uorigin[name]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: