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

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

相关推荐
To_OC1 小时前
一次 git reset 翻车,让我彻底分清了 hard 和 soft,也想通了 Vibe Coding 的本质
git·程序员·vibecoding
Ai拆代码的曹操2 小时前
Git 集成:AI 代理中的版本控制工作流设计
大数据·git·elasticsearch
lazy H2 小时前
Git clone 怎么用?克隆项目及常见问题完整教程
大数据·git·后端·学习·搜索引擎·github
m0_743697595 小时前
关于ftp与SELinux的冲突问题
git·github
前进的程序员5 小时前
VS Code Git 工作树:多分支并行开发体验
git·vs code·git工作树
半夜修仙6 小时前
二.Git分支管理
git
六bring个六8 小时前
git使用笔记
笔记·git
最后冰吻free11 小时前
git 不新增commit修改中间commit对应的文件
git
芳草萋萋鹦鹉洲哦11 小时前
【git】重新生成并添加 SSH Key(Mac)
git·macos·ssh
午安~婉12 小时前
git中http与ssh连接
git·http·ssh