I am setup with SourceTree and Bitbucket right now and i am doing some tests. I am new to Git but its seem pretty similar to what we have at the job so i know how branching/merging work.
I am a single developer but i still wanted to use Unity with Git to have the benefit of having Version Control and avoid mess later but i have some concern while looking at some articles.
1- About the .gitignore file. It seem there is many versions or thoughts about it everywhere. Some argue that we should include the Library folder, some say otherwise. Anyone got advices on this ?
2-Big assets in size. What are your way of having big assets in your projects and Git ? It seem bit files arenāt going well with Git.
3- Does Git work well with scenes and stuff that arenāt scripts ? Is there anything i should be aware of ?
4- What would be the best references for using Unity and Git ? Do you guys have any that proven to work well with your setup ?
Iām not an GIT expert, but the following works fine for me:
Go to Edit->ProjectSettings->Editor and set āVersion Controlā to āVisible Meta Filesā
In the same window set āAsset Serializationā to āForce Textā
Now youāre set up and all neccessary files will be āgittableā.
I donāt use gitignore on any files, as Unity generates temporary files for almost everything. You will most likely miss some files if you roll your GIT back, so i chose to git them all.
I have had files up to 2gb in my GIT. Works fine but was a stupid mistake, since it was a backup of the whole GIT itselfā¦
Make sure to change the things i mentioned at the top of this post.
Iām using GitExtensions which is a nice UI and works for me. Not sure if that counts as some kind of referenceā¦
Donāt include the library folder in the repo. You only need the ProjectSettings and the Assets folder in your repo. Inside of assets you can ignore the visual studio/monodevelop project files, because unity regenerates those.
big files suck in general. I donāt have a good solution for those and handle them on a project by project basis. (i.e. some projects do have them in the repo, some others have them outside of the repo)
unity 5 has a new smart merge tool. When your serialization is set to text(I think that is the default now) you can use this for merging scene files and prefabs. Unity - Manual: Smart merge
Hereās an example of a gitgnore I used. Remember to ignore copyrighted assets. I recommend creating a folder to put them all inside like āzAssetsā in my case.
I used SmartGit client after trying most of the alternatives.
@Zerot Bigs files were talking about really big files then ? (So some image which are 1mb of filesize that wonāt changes really in the futur shouldnāt cause any problems ?)
@Stardog I combined your gitignore with some other sample i saw somewhere. Thanks for this!
Binary files donāt work well with any version control system, as they donāt diff in a sensible way, and changes definitely wonāt merge well. This matters much less when your meta files are visible text files.
Large binary files may be a problem with GIT if theyāre either really large, or have loads of revisions, as all diffs of each change is included in the .git folder every user has with their checkout. But there are solutions to this, like tools such as Git Large File Support (https://git-lfs.github.com/) which seems to be the current āstandardā and many others.
So ā¦ stupid question maybe, but Iām kinda a git n00b: If I ignore a directory, using .gitignore, and that diretory contains assets etc that goes into my scenes, if I then clone the project on a new machine, and reinstall the assets of the directory manually (i.e. from a USB stick, or from the asset store) it should just work ? All the linking information linking assets to scenes / prefabs is in the prefab/scene files ?
Probably not. It depends exactly how you have things linked.
The Unity inspector uses GUIDs and .meta files to link between assets in your project. So if you delete and recreate the meta files, Unity will consider it a new asset and none of your inspector references will work.
On the other hand things if the references are all set up via script things will probably still work fine.