记录一次失败的向git提交代码,和解决的方法。(首次创建仓库)
背景:
向git push代码(创建一个新的仓库)
做法:
在github创建一个新的仓库------>本地新建文件夹------->依次执行了下面的命令
git init
git clone
git checkout -b master
放到文件夹中代码
git add .
git commit -m ""
git pull origin master:master(冒号两遍不能有空格)
git push
看似没有问题。
但是push会报错:
fatal: refusing to merge unrelated histories
那么运行下面命令:
$ git pull origin master --allow-unrelated-histories
结果:
From github.com:mangoyi/vue-elme
* branch master -> FETCH_HEAD
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
看着像是readme.me有冲突

这个配置导致,在创建仓库的时候就自动创建了readme
可以解决冲突,也可以往下看。
tip:
$ git push origin
上面命令表示,将当前分支推送到origin主机的对应分支。 如果当前分支只有一个追踪分支,那么主机名都可以省略。
$ git push -u origin master
如果当前分支与多个主机存在追踪关系,那么这个时候-u选项会指定一个默认主机,这样后面就可以不加任何参数使用git push。
$ git push -u origin master
上面命令将本地的master分支推送到origin主机,同时指定origin为默认主机,后面就可以不加任何参数使用git push了。
不带任何参数的git push,默认只推送当前分支,这叫做simple方式。此外,还有一种matching方式,会推送所有有对应的远程分支的本地分支。Git 2.0版本之前,默认采用matching方法,现在改为默认采用simple方式。
git push -f(不是自己一个人用的仓库别这么玩。)
push --force缩写
将本地的代码推送到远端,并覆盖。
所以可以强制推送并覆盖
git pull –f –all
git push –u origin master –f
或者
git push –u origin –f
前人种树:
https://blog.csdn.net/mangoyiy/article/details/75271758
https://www.jianshu.com/p/b03bb5f75250
记录一次失败的向git提交代码,和解决的方法。(首次创建仓库)的更多相关文章
- git提交代码冲突解决
1.git stash save "说明信息" 2.git stash lish 3.git pull 4.git stash pop stash@{编号}
- Git提交代码失败: empty ident name (for <>) not allowed
使用git提交代码,报错如下: 下午2:56 Commit failed with error 0 files committed, 1 file failed to commit: 升级 empty ...
- 在使用Git提交代码的时候犯了个低级错误
今天在使用git提交代码的时候,犯了个很低级的错误,按照一切流程当我add并commit提交代码,最后使用push到远程仓库, 接下来奇怪的事情发生了,push之后,查看远程仓库代码并没有发现提交记录 ...
- Git提交代码到主分区
git 提交代码,本地新建一个my分支,不从本地master分支直接上传,而是先从本地my分支上提交至本地master分支,然后本地master提交至远程master分支 上.前提是远程只有一个mas ...
- pycharm 使用Git提交代码到Github
pycharm 使用Git提交代码到Github pytharm 创建django项目,提交到github总是失败,在github创建项目拉下来后项目层级会多一层,为此查了一些资料,亲测如下方式可行. ...
- git提交代码到github
前言:转载请注明出处:http://blog.csdn.net/hejjunlin/article/details/52117504 git提交代码到github 命令汇总: git init git ...
- 使用git提交代码到github,每次都要输入用户名和密码的解决方法
自从使用git提交代码到github后,发现自己使用git的功力增长了不少,但也遇到不少问题.比如,使用git提交代码到github的时候,经常要求输入用户名和密码,类似这种: 网上有这么一种解决方法 ...
- Git提交代码报错Git push error:src refspec XXX matches more than one解决方案
Git提交代码push时,报错这个 error: src refspec master matches more than one. error: failed to push some refs t ...
- git提交代码到码云
日常代码一般提交到github比较多,但我还是钟爱马爸爸,没错就是码云. 码云是中文版的代码托管的网站,不存在打开网速问题,使用也蛮方便的,日常自己保存托管代码已经足够,平时使用git提交代码到码云是 ...
随机推荐
- LUOGU P2408 不同子串个数(后缀数组)
传送门 解题思路 后缀数组求本质不同串的裸题.\(ans=\dfrac{n(n+1)}{2} -\sum height[i]\). 代码 #include<iostream> #inclu ...
- AcWing 204. 表达整数的奇怪方式 (线性同余方程组)打卡
给定2n个整数a1,a2,…,ana1,a2,…,an和m1,m2,…,mnm1,m2,…,mn,求一个最小的整数x,满足∀i∈[1,n],x≡mi(mod ai)∀i∈[1,n],x≡mi(mod ...
- Spring源码剖析3:Spring IOC容器的加载过程
本文转自五月的仓颉 https://www.cnblogs.com/xrq730 本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查看 https ...
- Hibernate 和 JPA 注解
转载请注明:Hibernate 和 JPA 注解 | 言曌博客 1.@Entity(name="EntityName") 必须, name为可选,对应数据库中一的个表 2.@Tab ...
- RocktMq安装和简单使用以及报错收集
文章目录 安装 使用 报错 总结: rocketmq内存设置 配置brockerip 启动方式 如果往机器上部署,最好再本地看看报错吗 关于防火墙 看总结去吧 安装 准备: jdk1.8 maven ...
- 1、获取APP 冷/热启动时间
最近在研究Android APP性能测试.所以发现一些有趣的东西,在这里进行分享.我们先讲第一个内容,如何获取APP冷/热启动时间?为什么要做这个测试,道理其实很简单,如果启动APP特别耗时的话,用户 ...
- 机器学习技法笔记:02 Dual Support Vector Machine、KKT
原文地址:https://www.jianshu.com/p/58259cdde0e1 Roadmap Motivation of Dual SVM Lagrange Dual SVM Solving ...
- 力扣算法题—111.Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the sh ...
- 天道神诀---FTP服务
FTP 2种模式 主动模式(默认) 客户端以1024-65535之间某一端口发送指令到服务端的21端口,并建立连接.服务端接受到以后,以20端口去连接客户端,建立一条新的链接并传输数据 被动模式 客户 ...
- 两种接口传送数据协议(xml和json)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/tianyazaiheruan/article/details/37659983 规范性接口开发 ...