Git with Unity#
Git works very well with Unity because it’s text-based files, which are easy to merge and easy to commit. Anchorpoint also supports file locking capabilities for files like .unity and .prefab, as well as binary files that cannot be merged and should always be locked. It adds an additional metadata system to Git’s versioning functionality that is needed for file locking, art asset management, and having a centralized way to manage your project.
Anchorpoint automatically configures Git LFS if needed. This is important for binary files, so you won’t hit repository limits soon. It also comes with a default .gitignore template for Unity. You can connect Anchorpoint to any Git hosting provider such as GitHub, GitLab, Gitea or Azure DevOps.
Next to your Unity project, you can also use Anchorpoint for versioning and managing your art assets.
Using the Unity plugin#
Anchorpoint also provides a Unity plugin which allows you to commit directly from the Unity editor and see which files are locked. Although you can use Anchorpoint without the plugin, we strongly recommend that you use it, as it is the only way for file locking to work properly. You can learn more about the plugin in the integrations section.
Installing the plugin#
Open the Unity Package Manager via Windows/Package Manager. Click on the plus sign in the top left corner and select “Install package from Git URL”. Then paste in this URL: https://github.com/Anchorpoint-Software/ap-unity
and click on “Install”.
After that, you can click on Window/ Anchorpoint to open up the Anchorpoint plugin UI in Unity.
Workflow recommendations#
Use prefabs#
When working in a team, avoid putting to much content in the .unity scene. Split your project into a logical prefab structure. Then, work on a prefab that can be locked, so you will avoid conflicts and you also do not block other team members from working on your project.
Branching#
Keep the amount of branches to a minimum. You can learn more about the term “trunk based development”, where you only branch out from the main branch and merge back to main. You never branch out from a subbranch of main. For releases, have a release branch where you just merge your changes from main, once you have a release ready.
A proper .gitignore file#
A .gitignore is a configuration that filters out files that should be pushed to your central repository, such as the Library folder, which mostly contains cached files that can be regenerated at any time. Anchorpoint comes with a default .gitignore file. If you want to configure it yourself, perhaps because you have a unique setup, take a look at our blog article on how to configure a .gitignore file for Unity.
Your Git hosting provider#
Make sure your Git hosting provider provides enough LFS space for your projects. Providers like Azure DevOps do not charge for LFS space, but GitHub does. Just make sure you have it set up correctly. There is no need to configure anything else, just make sure that you have purchased enough storage packages.
Art assets#
It’s highly recommended that you keep your art assets (Blender, Photoshop, etc.) under version control. Use a separate repository for this to keep things tidy. Only put export formats (e.g. FBX files) into your Unity project.
Unity’s Smart Merge Tool#
When you both work on the same scene but on different objects, your changes can be merged. Git can merge text files, but it is not intelligent enough to merge Unity scenes. For that, you have to use their UnityYAMLMerge tool. To use it, you have to modify the .gitconfig file.
Open your Unity project in Windows Explorer.
Make hidden files visible.
Open a .git folder and open the config file in a text editor.
Add the following code:
[merge]
tool = unityyamlmerge
[mergetool "unityyamlmerge"]
trustExitCode = false
cmd = "'path to UnityYAMLMerge'" merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
“path to UnityYAMLMerge” should be replaced by the real path to the UnityYAMLMerge.exe on your computer. Usually, you can find it under: “C:/Program Files/Unity/Hub/Editor/2021.3.21f1/Editor/Data/Tools/UnityYAMLMerge.exe”. Make sure that you use forward slashes (/) and not backslashes (\) like Windows is doing.
In case of issues#
Feel free to join our Discord and ask for help. If you are a customer, please use our support@anchorpoint.app email for faster response times.