2015-12-21 238 views
3

當前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?或者詢問它爲什麼認爲沒有發現任何東西時會發生局部變化?

編輯:

好,做reset --merge後,我做了reset --hard然後git status通知我,我是落後1提交,這個時候,我做的一切git pull合併沒有問題。

那麼,如何避免上述情況呢? 或者這對於多操作系統環境來說很常見?
我的工作流程相當一致。我從拉開始,進行編輯,添加,提交和推送。但是,對於這個項目,有時候我在一臺Windows機器上,而另一些人則在使用OSX。在使用git的兩年中,我只是沒有遇到這個問題。

+0

你解決衝突?該文件被忽略? 'git status --ignored'的輸出是什麼? –

+0

'的分支主 \t彙編CSHARP-主編vs.csproj \t彙編CSHARP-Editor.csproj \t彙編CSHARP-Editor.sln \t彙編CSHARP-Editor.userprefs \t彙編CSHARP-VS .csproj的 \t大會-CSHARP-vs.sln \t大會-CSHARP-vs.userprefs \t彙編CSharp.csproj \t彙編CSharp.sln \t彙編CSharp.userprefs \t彙編UnityScript -vs.unityproj \t Assembly-UnityScript。unityproj \t庫/ \t STVE-csharp.sln \t STVE.sln \t STVE.userprefs 什麼承諾,工作目錄clean' – dval

+1

也許解決衝突是另一個問題?它不會告訴我有任何衝突,因爲它找不到本地更改。我在考慮花費30分鐘的時間,只是刪除本地文件並重新複製遠程文件可能會更簡單。 – dval

回答

0
  1. 從git的方式去除ProjectSettings/EditorBuildSettings.asset(簡單地將其移動到一個不同的名字,說ProjectSettings/EditorBuildSettings.asset.my
  2. 執行git pull。這次應該無縫完成。
  3. 比較ProjectSettings/EditorBuildSettings.assetProjectSettings/EditorBuildSettings.asset.my並決定哪個版本更加正確。
+0

謝謝。這比刪除整個存儲庫要快得多。我認爲這跟最終提交併強制合併是一樣的。接受這個答案是因爲它是一個更快的解決方案,而不是所有的重置取消廢話。 – dval

+0

沒有。通常我無法想象當你需要刪除整個回購時的情況。只是不要恐慌,坐下來,思考三次,並提出問題:) – user3159253

1

嘗試在另一分支上強制結帳,並再次結帳主帳單,例如,

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

然後再次把它:

git pull