如何让git覆盖不合理的本地更改?

目前git陷入了循环.由于本地更改,它无法合并.我无法存储本地更改,因为找不到任何更改.

$git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

$git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From https://private/url/project/
   e56777c..fac7619  master     -> origin/master
Updating e56777c..fac7619
error: Your local changes to the following files would be overwritten by merge:
    ProjectSettings/EditorBuildSettings.asset
Please, commit your changes or stash them before you can merge.
Aborting

$git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working directory clean

$git pull
Updating e56777c..fac7619
error: Your local changes to the following files would be overwritten by merge:
    ProjectSettings/EditorBuildSettings.asset
Please, commit your changes or stash them before you can merge.
Aborting

$git stash
No local changes to save

$git fetch

$git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working directory clean

$git stash
No local changes to save

$git merge
Updating e56777c..fac7619
error: Your local changes to the following files would be overwritten by merge:
    ProjectSettings/EditorBuildSettings.asset
Please, commit your changes or stash them before you can merge.
Aborting

$git stash
No local changes to save

this question上尝试接受的答案是行不通的.我收到以下错误:

$git fetch --all
Fetching origin

$git reset --hard origin/master
error: Entry 'ProjectSettings/EditorBuildSettings.asset' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'origin/master'.

有人能够可靠地reproduce and fix the last error:’无法重置索引……’但是他们建议的解决方法会为我产生以下错误:

$git add .

$git reset --merge fac7619
error: Entry 'ProjectSettings/EditorBuildSettings.asset' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'fac7619'.

无论如何强制git覆盖ProjectSettings?或者问它为什么认为当没有找到时会发生局部变化?

编辑:

好吧,在做了重置–merge之后,我做了重置 – 硬件然后git状态通知我我落后1提交,这次当我做git pull所有合并没有问题.

那么,如何避免上述情况呢?
或者这是多操作系统环境中常见的东西?
我的工作流程相当一致.我从拉动,编辑,添加,提交,推动开始.但是,对于这个项目,有时候我使用的是Windows机器,有些我正在使用OSX.我在使用git的2年内没有遇到过这个问题.

最佳答案 >从git方式中删除ProjectSettings / EditorBuildSettings.asset(只需将其移动到另一个名称,比如ProjectSettings / EditorBuildSettings.asset.my)

>执行git pull.这次应该无缝完成.

>比较ProjectSettings / EditorBuildSettings.asset和ProjectSettings / EditorBuildSettings.asset.my并确定哪个版本更正确.

点赞