我的情况似乎是一个错误....使用 git 2.21.0
我做了一个拉......它抱怨二进制文件:
warning: Cannot merge binary files: <path>
Auto-merging <path>
CONFLICT (content): Merge conflict in <path>
Automatic merge failed; fix conflicts and then commit the result.
然后,这里的任何答案都没有导致任何有意义的输出。
如果我查看我现在拥有的文件……那是我编辑的那个。如果我这样做:
git checkout --theirs -- <path>
git checkout --ours -- <path>
我得到输出:
Updated 0 paths from the index
我仍然有我的文件版本。如果我 rm 然后结帐,它会改为 1,但它仍然给我我的文件版本。
git mergetool 说
No files need merging
和 git status 说
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
一种选择是撤消提交......但我很不幸,我有很多提交,而这个糟糕的提交是第一个。我不想浪费时间重复这一点。
所以要解决这个疯狂:
我刚跑
git commit
这会丢失远程版本,并且可能会浪费一些空间来存储额外的二进制文件......然后
git checkout <commit where the remote version exists> <path>
这给了我远程版本
然后再次编辑文件......然后提交并推送,这可能再次意味着浪费空间与二进制文件的另一个副本。