git 解决push报错:[rejected] master -> master (fetch first) error: failed to push some refs to

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

1|0git操作

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

2|0报错信息

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.

3|0原因

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

4|0解决

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

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

 


__EOF__

本文作者BigTree
本文链接https://www.cnblogs.com/bigtreei/p/10180383.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   ZhuGaochao  阅读(12904)  评论(4编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
历史上的今天:
2017-12-26 前端基础 & 初识JS(JavaScript)
点击右上角即可分享
微信分享提示