1.首先是.gitignore的配置。
# Folder config file Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ # Windows Installer files *.cab *.msi *.msm *.msp # Windows shortcuts *.lnk ### Unity ### /[Ll]ibrary/ /[Tt]emp/ /[Oo]bj/ /[Bb]uild/ /[Bb]uilds/ /Assets/AssetStoreTools* # Folders designed to be part of repository, but not their content /_NonVersioned/* !/_NonVersioned/README.md /Assets/_NonVersioned/* !/Assets/_NonVersioned/README.md !/Assets/_NonVersioned/README.md.meta !/Assets/_NonVersioned.meta /Builds/* !/Builds/README.md # Files to be excluded ## Files generated by Visual Studio / MonoDevelop ExportedObj/ obj/ *.svd *.userprefs /*.csproj *.pidb *.suo /*.sln *.user *.unityproj *.booproj # Unity3D generated meta files *.pidb.meta ## Files generated by OS .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes ehthumbs.db Thumbs.db # Unity3D Generated File On Crash Reports sysinfo.txt # Builds *.apk *.unitypackage
2.然后是.gitattributes的配置(所有工程最開始就應該做好這兩步)。
* text=auto # keep lf on unity files *.asset text eol=lf *.meta text eol=lf *.prefab text eol=lf *.unity text eol=lf
3.在菜單Edit > Project Settings > Editor中打開Inspector,將Asset Serialization部分的Mode改成Force Text。
4.在SourceTree中設置如下選擇 工具->選項->比較->外部差異對比合並->自定義->
對比命令如下:D:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exe(找到自己電腦中UnityYAMLMerge.exe的路徑) 參數如下:merge -p $BASE $REMOTE $LOCAL $MERGED
5.在UnityYAMLMerge.exe所在的路徑,找到mergespecfile.txt文件,修改合並命令。
此項根據自己的需求修改,可以用下面推薦的N種方式。
修改之前的合並命令如下:
unity use "%programs%\YouFallbackMergeToolForScenesHere.exe" "%l" "%r" "%b" "%d"
prefab use "%programs%\YouFallbackMergeToolForPrefabsHere.exe" "%l" "%r" "%b" "%d"
修改之后的命令如下:
#Araxis Merge
unity use "%programs%\Araxis\Araxis Merge\compare.exe" /3 /a2 /wait /title1:"Other" /title2:"Base" /title3:"Local" "%l" "%b" "%r" "%d"
prefab use "%programs%\Araxis\Araxis Merge\compare.exe" /3 /a2 /wait /title1:"Other" /title2:"Base" /title3:"Local" "%l" "%b" "%r" "%d"
#Beyond Compare 4
unity use "%programs%\Beyond Compare 4\bcomp.exe" "%l" "%b" "%r" "%d"
prefab use "%programs%\Beyond Compare 4\bcomp.exe" "%l" "%b" "%r" "%d"
6.合並說明:通常情況下第一欄是local分支,第二欄是base分支,第三欄是remote分支。