Git所有冲突已标记解决 执行git rebase --continue失败无文件提示
问题现象
将个人分支变基到master分支时,处理完所有合并冲突、执行git add标记冲突解决状态后,git status明确提示(all conflicts fixed: run "git rebase --continue"),但实际执行git rebase --continue时返回无具体文件指向的报错:
You must edit all merge conflicts and then mark them as resolved using git add
复现该问题的Git版本为2.35.1.windows.2,对应控制台输出如下:
%> git status interactive rebase in progress; onto <commit-id> Last commands done (49 commands done): pick <commit-id> .... pick <commit-id> .... (see more in file .git/rebase-merge/done) Next commands to do (38 remaining commands): pick <commit-id> .... pick <commit-id> .... (use "git rebase --edit-todo" to view and edit) You are currently rebasing branch 'branch-1' on '<commit-id>'. (all conflicts fixed: run "git rebase --continue") Changes to be committed: (use "git restore --staged <file>..." to unstage) .... Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) .... %> git rebase --continue You must edit all merge conflicts and then mark them as resolved using git add %> git --version git version 2.35.1.windows.2
排查解决步骤
按优先级从高到低依次尝试以下操作:
- 执行
git add -A将工作区所有变更(包括容易被忽略的行尾换行符变更、文件权限位变更)全部暂存,再重试git rebase --continue。绝大多数这类问题都是漏加了非业务类自动变更,git status的提示逻辑没把这类变更识别为阻塞项,但rebase的前置校验会直接拦截流程。 - 上一步无效则扫描Git元数据目录的残留冲突标记:执行
grep -rE "^(<<<<<<<|=======|>>>>>>>)" .git/,如果返回结果中存在.git/rebase-merge/路径下的临时文件带冲突标记,手动删除对应异常标记行并保存,再重试继续变基。 - 针对2.35.1.windows.2版本的已知专属bug:该版本rebase流程对
core.autocrlf自动换行配置的校验存在逻辑错误,临时执行git config core.autocrlf false关闭自动换行转换,再执行git add -A后重试变基继续操作,等变基完成后再把该配置改回原本的设置即可。 - 上述操作都无效时,执行
git rebase --abort终止当前变基流程,升级Git到2.36及以上的Windows稳定版本后重新发起变基,该问题对应的校验bug在2.36版本已被官方修复。 - 不想升级版本的兜底方案:终止当前变基后,改用merge方式合入master分支代码,绕开该版本rebase的异常校验逻辑。
内容的提问来源于stack exchange,提问作者Ajoy Bhatia
相关产品推荐
相关产品推荐

