2012-11-21 66 views
4

我有一個文件調用a.uni,我必須合併解決方案。 但git把a.uni當成二進制文件。 當我合併的解決方案,它總是顯示:如何處理文件不是二進制文件(git)

警告:不能合併二進制文件:a.uni(HEAD與549af46 ...測試) 錯誤:無法適用549af46 ...測試 提示:後解決衝突,標記修正後的路徑 提示:用'git add'或'git rm' 提示:並用'git commit'提交結果 其他人可以幫我! 非常感謝。

+0

那麼,.uni文件中有什麼?你的.gitattributes文件的內容是什麼? – Perception

+0

實際上,它只是uni文件中的一個文本,並且在我的存儲庫中沒有.gitattributes。 – kane

回答

4

由於您的.uni文件實際上是一個文本文件,我想它必須包含一些NUL字符(請參閱「How to determine if Git handles a file as binary or as text?」)。

這取決於您想要如何管理合並。

如「Tell git not to merge binary files but to choose」中所述,您可以在.gitattributes文件中指定合併管理器,該合併管理器將根據您的策略進行合併。

至少,在 「​​」,你可以嘗試,並指定(仍然離子的.gitattributes文件):

*.uni -text crlf diff 

對於Unicode文件,在看 「Can I make git recognize a UTF-16 file as text?」,您可以:

  • 任一定義自定義的diff或合併工具支持該格式: git config --global diff.tool vimdiff ; git difftool commit1 commit2
  • 或定義喜歡的屬性: * .uni差異合併-crlf

你也應該確保:

+0

現在,我知道爲什麼git將我的文件視爲二進制文件。因爲它是一個unicode文件。但我仍然不知道如何解決這個問題~~~ – kane

+0

@ user1584490你試過'* .uni -text crlf diff' gitattributes指令嗎? – VonC

+0

我試過了,但它不起作用~~ – kane

相關問題