9

We're using "Visible Meta Files" as our internal version control at the moment (if it's not the correct approach, we wouldn't have a problem changing it), but currently confused as to what's best to do when working on a branch.

For instance, latest work that I've done, is implement an IAP plugin, which created loads of folders and files in different places in the project, as well as the meta files connected with them all.

I went about this in my normal git work approach, by doing the work in a branch, and then bring it into the master branch when it's ready. Unfortunately, if I do this, when I have to do some work on another branch, when I swap to that branch, Unity recreates all these meta files from the folders created on that other branch, that then mess up any sort of clean merging, or similar.

Thusfar, what I've chosen to do is, when merging, close Unity, delete all these leftover meta files / allow the merge to overwrite local files, but I'm assuming there must be a better way to do this, no?

2 Answers 2

2

This an annyoing behaviour of Unity. Just make sure to to properly commit/push the meta files. I recommend having multiple 'local copies' of the branches you work on and only handle the meta files once you merge/re-integrate the new features. This way you will treat them as separate projects in Unity.

Sign up to request clarification or add additional context in comments.

Comments

1

The proper way of dealing with git and unity is having a proper gitignore. This will make git ignore any files with specific extensions from being committed, but allow them to exist inside the working directory (useful for meta or solution files). The Unity Manual recommends committing the meta files to the repository. I normally use GitHub's Unity Gitignore

I have been doing the following on every project I work on

  1. Setup unity
    • Edit > Project Settings > Editor
    • Set Version Control Mode to "Visible Meta Files"
    • Set Asset Serialization Mode to "Force Text"
  2. Commit GitHub's Unity Gitignore to the project

This should make merging easy for git as you are using text files as opposed to some binary some text (or all binary). This workflow has saved friends and I countless headaches at hackathons. Just remember to only have one person work on/commit to a scene at a time!

5 Comments

All of those settings are our settings, and our gitignore is the base we used, when we set the project up. So, none of this actually helps the situation I'm in. Also, scenes are nothing to do with what I'm talking about. Think of this, you're on a branch, and create the folder Editor/Internal, and work there, but at the same time, coincidentally, someone else created Editor/Internal, on master, two different Internal.meta files will be created, and as far as I'm aware, I can't tell a good way about which to choose, or how to merge properly.
I understand now, I don't think that was exactly clear in the original post. I mentioned the scene thing because that is a common thing people forget. From what you are describing the only way I can think of is delete meta like you are saying, manually do the merge conflicts (the meta files are based on yaml), or make sure no one is creating the same folders on different branches
You could also add the .meta files to your gitignore. Its not ideal if you have a big project as Unity will have to remake them whenever you switch branches, but if that is a common issue your team is running into it may be worth the time to wait to remake it
Deleting the meta files in bulk isn't really an option either, as it can cause issues with linkages that have been set up. IE. if you've a prefab in that Internal folder which then has a button connected within it, deleting the meta information from that can then (sometimes) disconnect that. To be honest, since I made this post, we've become more comfortable in general with Unity, and I don't actually think there's a perfect solution with Source Control. Just be careful, know what you're doing, and don't do huge merges / stay away from master from too long without syncing up.
@seaders I think this should be an answer rather than a comment. Thanks for the opinions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.