-
Notifications
You must be signed in to change notification settings - Fork 0
Git with Unity
Alex Feinstein edited this page Apr 12, 2020
·
1 revision
Go to Edit > Project Settings > Editor
- Version Control > Mode to Visible Meta Files
- Asset Serialization > Mode to Force Text
Unity ships with special Git-compatible merge tool - SmartMerge Add the following to git-config
[mergetool "unityyamlmerge"]
cmd = <PATH_TO_EXECUTABLE> merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
trustExitCode = false
keepTemporaries = true
keepBackup = false
[merge]
tool = unityyamlmerge
On macOS:
'/Applications/Unity/Unity.app/Contents/Tools/UnityYAMLMerge'
On Windows:
'C:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exe'
Next time you encounter a conflict that Git can't automatically resolve, run:
$ git mergetool
For example:
$ git merge feature1
Auto-merging Assets/Scenes/GameOver.unity
CONFLICT (content): Merge conflict in Assets/Scenes/GameOver.unity
Automatic merge failed; fix conflicts and then commit the result.
$ git mergetool
Merging:
Assets/Scenes/GameOver.unity
Normal merge conflict for 'Assets/Scenes/GameOver.unity':
{local}: modified file
{remote}: modified file
Conflicts:
Conflict handling:
Assets/Scenes/GameOver.unity seems unchanged.
Was the merge successful [y/n]? y
Note, Git sometimes thinks that a file is unchanged when in fact the conflicts have been resolved successfully. To test, try opening the conflicted file in Unity.
- If it really is unchanged and there are still conflict markers, it will fail to open
- If it opens successfully, you can check the result of the merge in the Unity Inspector (it should have the new values from both sides of the merge) and then commit it as normal.
# Unity
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
sysinfo.txt
*.pidb.meta
Also ignore various IDE files
# VS/Rider/MD/Consulo
ExportedObj/
.consulo/
.idea/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
Ignore build artifacts
# Builds
*.apk
*.unitypackage
*.app
*.exe
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
*.physicsMaterial2D merge=unityyamlmerge eol=lf
*.physicMaterial merge=unityyamlmerge eol=lf
*.asset merge=unityyamlmerge eol=lf
*.meta merge=unityyamlmerge eol=lf
*.controller merge=unityyamlmerge eol=lf
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
*.physicsMaterial2D merge=unityyamlmerge eol=lf
*.physicMaterial merge=unityyamlmerge eol=lf
*.asset merge=unityyamlmerge eol=lf
*.meta merge=unityyamlmerge eol=lf
*.controller merge=unityyamlmerge eol=lf
## git-lfs ##
# Images
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.ai filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.cubemap filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
# Audio
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
# Video
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.mov filter=lfs diff=lfs merge=lfs -text
# 3D Objects
*.FBX filter=lfs diff=lfs merge=lfs -text
*.fbx filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text
# Other
*.a filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
*.aif filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.rns filter=lfs diff=lfs merge=lfs -text
*.reason filter=lfs diff=lfs merge=lfs -text
*.lxo filter=lfs diff=lfs merge=lfs -text