目前 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
尝试此问题的被接受的答案,但不起作用。我得到了以下错误:
$ 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'.
有人能够可靠地重现和修复最后一个错误:'无法重置索引...',但他们建议的解决方法对我来说会产生以下错误:
$ 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?或者问它为什么认为有本地更改,但没有发现任何更改?
编辑:
好的,在执行reset --merge后,我执行了reset --hard,然后git status通知我落后了1个提交。这次当我执行git pull时,一切都合并得很顺利。
那么,如何避免上述情况? 还是这在多操作系统环境中很常见? 我的工作流程相当一致。我从拉取开始,进行编辑,添加,提交,推送。但是,对于这个项目,有时我使用Windows机器,有时我使用OSX。在使用git两年中,我只是没有遇到这个问题。
git status --ignored
的输出是什么? - Edward Thomson