试图将更改推送到 GitHub,但是远程仓库已经包含了您本地没有的工作(可能是其他人提交的修改)

这通常是由于其他人或其他仓库推送到了相同的分支上,导致您的本地仓库和远程仓库之间存在冲突。

错误信息:

To github.com:8upersaiyan/CKmuduo.git ! rejected main -> main (fetch first) error: failed to push some refs to 'github.com:8upersaiyan/CKmuduo.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.

解决方法:

git config --global pull.rebase true # 设置默认为变基策略
git pull origin main #从远程同步到本地

解决完远程同步到本地的问题,在解决从本地到网络的同步:

使用:

git add .
git commit -m "解决冲突并更新"
git push origin main

把本地的修改推送到网络上。

相关推荐
Irissgwe9 小时前
第 6 篇:Git 分支进阶:分支策略、stash、bugfix 和 feature 开发
git
wok1579 小时前
Git Bash 执行中文命令报错 127:MSYS 参数编码 bug 排查与修复
git·bug·bash
霸道流氓气质1 天前
CodeBuddy中使用 MCP 工具将 XMind 思维导图转换为 Markdown —— 实操流程汇总
git·myeclipse·xmind
OsDepK1 天前
mimo code安装教程
git·电脑·ai编程
NexTunnel1 天前
公司老项目还在 SVN,远程维护怎么做更稳?
git·svn·gitlab·远程工作·nextunnel
满天星83035772 天前
【Git】原理及使用(七) (多人协作 [下])
git
郡杰2 天前
Git基础与开发平台搭建
git·后端
钟智强2 天前
我警告了 329 天
git·php·wordpress·webshell
乐观的冷风2 天前
我们需要将文件添加到暂存区才能提交,而移除文件后是无法添加到暂存区的,那么怎么移除一个文件让GIT不再将其纳入版本控制呢?上图中GIT已经给出了说明:
git
tjl521314_212 天前
Git SSH Host Key Verification Failed 问题排查与解决
运维·git·ssh