4

Currently git is stuck in a loop. It can't merge because of local changes. I can't stash local changes because none are found.

$ 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

Trying the accepted answer on this question, doesn't work. I get the following error:

$ 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'.

Someone is able to reliably reproduce and fix the last error: 'Could not reset index...' but the workaround they suggest produces the follow error for me:

$ git add .

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

Is there anyway to force git to overwrite the ProjectSettings? or ask it why it thinks there are local changes when none are found?

Edit:

Ok, after doing reset --merge, I did reset --hard then git status notified me I was behind 1 commit, This time when I did git pull everything merged with no issues.

So, how can the above scenario be avoided? Or is this something that is common to multi-OS environments?
My workflow is fairly consistant. I start with a pull, make edits, add, commit, push. But, for this project, sometimes I am on a windows machine, others I am using OSX. I just have not run into this issue in 2 years of using git.

Community
  • 1
  • 1
dval
  • 368
  • 5
  • 14
  • Are you resolving conflicts? Is that file ignored? What is the output of `git status --ignored`? – Edward Thomson Dec 21 '15 at 16:11
  • `On branch master Assembly-CSharp-Editor-vs.csproj Assembly-CSharp-Editor.csproj Assembly-CSharp-Editor.sln Assembly-CSharp-Editor.userprefs Assembly-CSharp-vs.csproj Assembly-CSharp-vs.sln Assembly-CSharp-vs.userprefs Assembly-CSharp.csproj Assembly-CSharp.sln Assembly-CSharp.userprefs Assembly-UnityScript-vs.unityproj Assembly-UnityScript.unityproj Library/ STVE-csharp.sln STVE.sln STVE.userprefs nothing to commit, working directory clean` – dval Dec 21 '15 at 16:15
  • 1
    Maybe resolving conflicts is another issue? it doesn't tell me there are any conflicts, because it can't find local changes. I am thinking for the 30 minutes I have spent on this, it might be easier to just delete local, and re-clone remote. – dval Dec 21 '15 at 16:19
  • Possible duplicate of [How to ignore error on git pull about my local changes would be overwritten by merge?](http://stackoverflow.com/questions/14318234/how-to-ignore-error-on-git-pull-about-my-local-changes-would-be-overwritten-by-m) – kenorb Mar 16 '16 at 12:46

2 Answers2

3
  1. remove ProjectSettings/EditorBuildSettings.asset from the git way (simply move it to a different name, say ProjectSettings/EditorBuildSettings.asset.my)
  2. perform git pull. It should be completed seamlessly this time.
  3. compare ProjectSettings/EditorBuildSettings.asset and ProjectSettings/EditorBuildSettings.asset.my and decide what version is more correct.
user3159253
  • 16,836
  • 3
  • 30
  • 56
  • Thanks. This is much faster than deleting the entire repository. I think it is ultimately the same as going back 1 commit and forcing a merge. Accepting this answer because it's a quicker solution, than all the reset-fetch nonsense. – dval Dec 21 '15 at 21:31
  • not at all. generally I can't imagine a situation when you need to remove an entire repo. Just don't panic, sit still, think twice and ask questions on SO :) – user3159253 Dec 22 '15 at 00:13
  • Worked as charm! – BugHunter Mar 16 '20 at 10:19
1

Try forcing checkout on another branch, and checkout master again, e.g.

git checkout origin/master -f
git checkout master -f

Then pull it again:

git pull
kenorb
  • 155,785
  • 88
  • 678
  • 743