git 添加远程仓库后无法push
2017-08-30 16:35
162 查看
push的时候提示fatal:refusingtomergeunrelatedhistories
假如我们的源是origin,分支是master,那么我们需要这样写
提示:
hint:Updateswererejectedbecausethetipofyourcurrentbranchisbehind
hint:itsremotecounterpart.Mergetheremotechanges(e.g.'gitpull')
hint:beforepushingagain.
hint:Seethe'Noteaboutfast-forwards'in'gitpush--help'for
details.
假如我们的源是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]
相关文章推荐
- mac机器下远程仓库添加完毕之后,却无法上传应有的内容。
- git无法push本地代码至远程仓库解决方法(附git一点芝麻那么大的原理)
- 解惑:git 创建远程仓库无法push
- 创建局域网内远程git仓库,并将本地仓库push推到远程仓库中
- git本地仓库重新建立错误,无法push。
- maven的eclipse插件在增加依赖(Add Dependency)时无法搜索远程仓库
- Git-添加远程仓库
- maven 添加jar到远程仓库
- git实现自动化部署,同时push到多个远程仓库
- 【Git学习笔记】将标签push到远程仓库
- Xcode9如何push到远程git仓库
- Git添加到远程仓库
- 创建局域网内远程git仓库,并将本地仓库push推到远程仓库中
- git把本地项目push到远程仓库
- github提交代码无法改变远程仓库路径
- GIthub添加远程仓库
- GitHub基础学习-在eclipse中生成“public key”(公钥)并添加到GitHub远程仓库中
- Git push远程仓库总是需要账号密码?
- 如何将一个本地项目和github远程仓库相关联并且使用户有push和fetch等权限
- 命令行方式下在Github上新建远程仓库并PUSH