目前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?或者问它为什么认为当没有找到时会发生局部变化?
好的,在完成reset --merge
之后,我做了reset --hard
然后git status
通知我我落后于1次提交,这次我做git pull
时所有内容都合并而没有任何问题。
那么,如何避免上述情况呢? 或者这是多操作系统环境中常见的事情? 我的工作流程相当一致。我从拉动,编辑,添加,提交,推动开始。但是,对于这个项目,有时候我使用的是Windows机器,有些我正在使用OSX。我在使用git的2年内没有遇到过这个问题。
答案 0 :(得分:1)
ProjectSettings/EditorBuildSettings.asset
(只需将其移至其他名称,例如ProjectSettings/EditorBuildSettings.asset.my
)git pull
。这次应该无缝完成。ProjectSettings/EditorBuildSettings.asset
和ProjectSettings/EditorBuildSettings.asset.my
并确定哪个版本更正确。答案 1 :(得分:1)
尝试在另一个分支上强制结帐,然后再次结帐,例如
git checkout origin/master -f
git checkout master -f
然后再拉一次:
git pull