git push origin master提交报错解决办法

简介: git push origin master提交报错解决办法

使用git push origin master将本地提交推送到远程仓库的时候

遇到了这样的一个报错

wangting@DESKTOP-O81VEVO MINGW64 ~/Desktop/wisdom_inventory_admin (master)
$ git push origin master
To https://gitee.com/wangyoko/wisdom_inventory_admin.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/wangyoko/wisdom_inventory_admin.git'
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 origin master --allow-unrelated-histories

将远程仓库的Readme. md一起拉下来同步到本地

再次执行

git push origin master


ok,远程仓库同步代码

相关文章
|
8天前
|
安全 开发工具 git
git分布式版本控制系统及在码云上创建项目并pull和push
通过本文的介绍,我们详细讲解了Git的基本概念和工作流程,并展示了如何在码云上创建项目及进行pull和push操作。Git作为一种分布式版本控制系统,为开发者提供了强大的工具来管理代码变更和协作开发。希望本文能帮助您更好地理解和使用Git及码云,提高开发效率和代码质量。
29 16
|
9天前
|
安全 开发工具 git
git分布式版本控制系统及在码云上创建项目并pull和push
通过本文的介绍,我们详细讲解了Git的基本概念和工作流程,并展示了如何在码云上创建项目及进行pull和push操作。Git作为一种分布式版本控制系统,为开发者提供了强大的工具来管理代码变更和协作开发。希望本文能帮助您更好地理解和使用Git及码云,提高开发效率和代码质量。
37 18
|
3月前
|
开发工具 git
git分支管理master/hotfix/develop/feature/release
采用合理的Git分支管理模型可以显著提升团队协作效率和代码管理的质量。本文介绍的 `master`、`develop`、`feature`、`release`和 `hotfix`分支模型是一个行之有效的方法,适用于大多数软件开发项目。通过清晰地划分各个分支的职责,团队成员可以更专注于各自的开发任务,同时确保代码库的稳定性和可维护性。
143 2
|
3月前
|
网络安全 开发工具 git
解决fatal:remote error:You can’t push to git://github.com/username/*.g
通过上述诊断与修复步骤,绝大多数的推送错误都能得到有效解决,确保您的Git工作流顺畅无阻。
299 1
|
4月前
|
编译器 网络安全 开发工具
git学习五:切换本地仓库出现的问题。修改git配置初始化。error:src refspec master does not match any。错误总结,送上几个案例
这篇文章是关于Git使用中遇到的一些问题及其解决方案的总结,包括切换本地仓库时的问题、修改Git初始化配置、以及解决"error: src refspec master does not match any"错误等。
136 0
|
开发工具 git
git出现报错:src refspec master does not match any
git出现报错:src refspec master does not match any
927 0
|
27天前
|
Java 网络安全 开发工具
Git进阶笔记系列(01)Git核心架构原理 | 常用命令实战集合
通过本文,读者可以深入了解Git的核心概念和实际操作技巧,提升版本管理能力。
|
28天前
|
网络安全 开发工具 git
mac git clone命令提示git@gitee.com: Permission denied (publickey).问题修复
mac git clone命令拉取gitee上项目代码时提示密钥问题
|
2月前
|
机器学习/深度学习 Shell 网络安全
【Git】Git 命令参考手册
Git 命令参考手册的扩展部分,包含了从基础操作到高级功能的全面讲解。
74 3
|
3月前
|
开发工具 git
git 常用命令
这些只是 Git 命令的一部分,Git 还有许多其他命令和选项,可根据具体需求进行深入学习和使用。熟练掌握这些命令能够帮助你更高效地管理代码版本和协作开发。