试图将更改推送到 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

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

相关推荐
妙码生花1 小时前
GIT 提交规范
git
云雀衔光3 小时前
多个 MCP Server 怎么编排:数据库 / Redis / Git / 飞书一把梭
java·数据库·人工智能·redis·git·语言模型·飞书
Java后端的Ai之路4 小时前
Git pull弹出vim编辑器完整排查指南
开发语言·人工智能·git·编辑器·vim
云泽80814 小时前
Git 版本控制系统(下):从 .git 目录结构到冲突解决机制详解
大数据·git·elasticsearch
麻辣布丁21 小时前
Git冲突原因与解决方法全解
大数据·git·elasticsearch
一支黑色の铅笔1 天前
VSCode 克隆Git项目
ide·git·vscode
拽着尾巴的鱼儿1 天前
Idea:Cannot Run Git 无法运行git
java·git·intellij-idea
y小川1 天前
【git】移除远端已删除的git分支
git
OsDepK2 天前
项目快速Git至仓库(完整版)
大数据·git·elasticsearch·搜索引擎
妙码生花2 天前
使用git更新ai-go-admin框架
前端·人工智能·git·golang·typescript·php