解决Git 冲突后本地提交丢失/未推送问题

1.确认你的提交还在本地

复制代码
git log --oneline -10

c6b069b (HEAD -> match) Merge branch 'match' ofxxxx

135d11c xxxx

eba4802 (origin/match) xxxx

695a327 xxxx

2.取消这个 merge,回到你原始提交

复制代码
git reset --hard 135d11c

3.拉取远程最新代码,并 rebase 你的提交到顶端

复制代码
# 拉取远程最新(但不自动 merge)
git fetch origin

# 把你的提交 rebase 到 origin/match 之上
git rebase origin/match

4.强制推送

复制代码
git push --force-with-lease origin match
相关推荐
阿民不加班13 小时前
【Git】git拉取远端但是本地存在不想提交文件处理
git
Selina K13 小时前
在windows安装git
git
周杰伦fans20 小时前
如何将 Feature 分支同步到 Master 主分支:一次完整的 Git 合并实战
git
jiayi_199920 小时前
git创建new branch
git
__Witheart__21 小时前
通过交互式 Rebase 合并部分提交到远程分支的操作步骤
git
魔都吴所谓1 天前
【Tools】Repo 工具完整使用手册
git
tianyuanwo1 天前
跨 Gerrit 项目迁移分支并保留完整历史:一份可操作的 Git 指南
git·代码迁移
玄奕子1 天前
VS Code 上传 GitHub 全流程(Windows 环境):HTTP 与 SSH 两种方案(含常见报错排查)
git·http·ssh·github·嵌入式开发
一只游鱼1 天前
如何让本地的敏感配置文件不上传到git仓库
git·elasticsearch
渣渣馬1 天前
shell的if多条件
git·ssh