今天对代码进行了修改优化,然后往往远程push,但push后报错了

git操作

git add .
git commit -m"fix"
git push origin master:dev-gaochao

报错信息

To https://amc-msra.visualstudio.com/trading-algo/_git/real-trading
! [rejected] master -> dev-gaochao (fetch first)
error: failed to push some refs to 'https://amc-msra.visualstudio.com/trading-algo/_git/real-trading'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因

之所以出现这个原因,是因为我在线上生成、编辑了README.md文件,而本地代码文件中不包含它,所以线上线下就对不上了。

解决

将线上、线下代码进行合并

git pull --rebase origin dev-gaochao

然后再进行push

git push origin master:dev-gaochao

成功:

Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.90 KiB | 487.00 KiB/s, done.
Total 7 (delta 4), reused 0 (delta 0)
remote: Analyzing objects... (7/7) (13 ms)
remote: Checking for credentials and other secrets... (1/1) done (1008 ms)
remote: Storing packfile... done (157 ms)
remote: Storing index... done (87 ms)
To https://amc-msra.visualstudio.com/trading-algo/_git/real-trading
1919525..6f3asa4dd6 master -> dev-gaochao

git 解决push报错:[rejected] master -> master (fetch first) error: failed to push some refs to的更多相关文章

  1. git提交远程报错[rejected] master -> master (fetch first)

    1 先下载git for windows 然后一直点下一步安装. 2 安装之后,选择git gui.生成ssh 链接 git 公钥. 用命令也可以: $ ssh-keygen -t rsa -C &q ...

  2. To ssh://xxx.com:8022/test/project.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'ssh://xxx.com:8022/test/project.git'

    To ssh://xxx.com:8022/test/project.git ! [remote rejected] master -> master (pre-receive hook dec ...

  3. 关联吸纳的remote首次push报错rejected

    F:\abb-iot\DmsAPI\DmsAPI (master -> origin) λ git push --set-upstream github master To github.com ...

  4. Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......

    今天在使用Git回退到之前某个版本的代码时,进行push时出现如下错误: ! [remote rejected] master -> master (pre-receive hook decli ...

  5. rpm安装rpm-package报错:Header signature NOKEY 和 error: Failed dependencies:

    以前经常遇到这个问题,一直未有记录,今天记录下来: 在安装rpm包的时候报错误如下: Question 1: warning: *.rpm: Header V3 DSA signature: NOKE ...

  6. [原]rpm安装rpm-package报错:Header signature NOKEY 和 error: Failed dependencies:

    以前经常遇到这个问题,一直未有记录,今天记录下来: 在安装rpm包的时候报错误如下: Question 1: warning: *.rpm: Header V3 DSA signature: NOKE ...

  7. git上传文件夹报错: ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/taminachen/rjxm.git' hint: Updates were rejected because the remote contains work

    使用git上传本地文件夹到远程仓库,使用如下命令:git push -u origin master时报错 原因是在GitHub创建仓库时创建了readme文件,但是本地没有这个文件,造成本地目录与远 ...

  8. git push报错! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://gitee.com/XXX.git

    git pull origin master --allow-unrelated-histories  //把远程仓库和本地同步,消除差异 git add . git commit -m"X ...

  9. git 报错:error: failed to push some refs to 'https://github.com/Anderson-An/******.git'(已解决)

    提交push 报错: $ git push origin masterTo https://github.com/Anderson-An/******.git ! [rejected] master ...

随机推荐

  1. js----Navigator对象,查看浏览器信息,Screen对象,查看屏幕信息

    Navigator对象 Navigator 对象包含有关浏览器的信息,通常用于检测浏览器与操作系统的版本. 对象属性: 查看浏览器的名称和版本,代码如下: <script type=" ...

  2. 善用php-fpm的慢执行日志slow log,分析php性能问题

    众所周知,mysql有slow query log,根据慢查询日志,我们可以知道那些sql语句有性能问题.作为mysql的好搭档,php也有这样的功能.如果你使用php-fpm来管理php的话,你可以 ...

  3. Pyspider学习

    简介 国人编写的强大的网络爬虫系统并自带强大的WebUI,采用Python语言编写吗,分布式架构.支持多种数据库后端 pyspider中文网站:http://www.pyspider.cn/ 源码网址 ...

  4. linux在桌面和dos之间的切换

    在linux 终端执行某条命令(init 5)时 提示一下错误 init :Need to be root 是提示要获取root权限 输入su 回车输入密码

  5. php中的 file_get_contents(‘php://input’)

    今天用CI框架整合微信发现了一个没见过的 file_get_contents('php://input'); 这个家伙是干嘛用的,然后自己直接写了验证的代码.好吧 废话不多说直接看下面的代码. < ...

  6. C语言 函数指针三(反向调用)

    动态库代码 //简单的动态库开发----报文发送 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib. ...

  7. Collection 和 Collections的区别?

    Collection 和 Collections的区别? 解答:Collection是java.util下的接口,它是各种集合的父接口,继承于它的接口主要有Set 和List:Collections是 ...

  8. Java 的数组

    几乎所有程序设计语言都支持数组.在C和 C++里使用数组是非常危险的,因为那些数组只是内存块.若程 序访问自己内存块以外的数组,或者在初始化之前使用内存(属于常规编程错误),会产生不可预测的后果 (注 ...

  9. php视频教程

    网址:http://www.php100.com/index.html

  10. Ubuntu14.4下安装FTP

    今天学习了Ubuntu上安装ftp的实例. 1.window上已经安装wamp(windows + apache + mysql + php) 2.window上已安装VMware Workstati ...