fatal You are in the middle of a merge -- cannot amend.
2024年1月29日小于 1 分钟约 286 字
error
fatal: You are in the middle of a merge -- cannot amend.solution
方法一:
在本地分支 1、git stash 将修改的文件保存下来
2、git reset --merge 取消合并
3、git rebase 重新定位到和追踪分支相同的基准。
如果 3 有冲突
1)解决冲突
2)git add + 文件
3)git rebase (--continue)4、git stash pop 将保存文件弹出
如果4 有冲突
1)解决冲突
2)git add + 文件5、git commit --amend
6、git push -f
方法二:
解决方法:
git reset --merge
注:取消合并
git rebase
注:将当前分支重新设置基线
git diff -w +冲突的文件
注:查看冲突点,修改冲突的文件,达到提交的状态。
git rebase --continue
注:让rebase继续处理
git add
注:追加修改后的文件
git rebase --continue
注:让rebase继续处理,查看是否有其他文件未提交
git commit --amend
注:提交修改后的代码
git push +分支
注:提交到某个分支中 参考文档
