Let's talk about Unity + Git: Best Practices and Workflow
I've been using Collab, up until this point, and it's been great! Well, great for simplicity, minus some bugs and lacking feats I miss from Git: By this point, I'm wanting to go beyond simplicity and start a GitLab pipeline. I also miss some Git feats like "Discard All Local Changes" and "Local Commits". So I'm starting to migrate to Git[Lab].
Because Unity has countless little files, there seems to be a lot to do to prep for such a migration -- at least, an ideal one!
What are the best practices for using Git with Unity?
Here is what I know (or, at least, what I think I know! Correct me in comments):
GitHub has a recommended GitIgnore file here. There's probably more to addon to it.
I read that empty directories are an issue, so I found this script that cleans empty dirs.
When you add something to gitignore, it doesn't ignore the associated meta file. So I found this "pre commit" script that does just that -- if something is gitignored, also gitignore the associated meta fire.
It's already in the .gitignore file linked above, but better said out loud to reiterate: Git ignore the ENTIRE /Library dir.
Don't use GitHub because they soft limit you to 1GB (unless you're a tiny project) and you must pay to make your repo private. Use GitLab (either hosted or on your own server). 10gb cap, unlimited repos, can make any private - bursting with features and integrations. FREE. Pretty amazing.
There's another reason to use GitLab: Continuous Integration + Runners: I'm still learning this, but it seems you can set a pipeline to upload your game directly to Steam after it detects a pull. It can also do some tests before it does so: anything you want. Since our project is over 10gb, I recently setup "GitLab CE" on our API server ($25/mo vps), so I now have unlimited storage.
My planned, automated workflow is this: I'm going to later use Unity Cloud Build to compile, connect it to my GitLab server to trigger a webhook to pull, copy the files to my Steamworks dirs, then upload via Steam pipeline: Fully automated, no CPU used locally. I would just have to turn the build live manually.
Enabling cache server in prefs on a SSD seems to increase speed of sync'ing files.
GitHub for Windows is soo friendly, but doesn't play too well with GitLab. I heard you can drag GitLab URLs to GitHub for Windows and it'll pick it up. This is probably my fav interface, so I'd try this later. However, sometimes it can go weird when you have BIG pushes. Free.
I tried GitKraken and the interface LOOKS awesome (with the catchiest name out there), but it's super buggy, "too simple", freezes, crashes, no progress status (infinite spinny wheel), and apparently known to crash for any project above 150mb+ in size. No LFS support. Free, but.... yeah.
I'm currently using SmartGit: Works well, does things fast, and the interface feels like Filezilla. I'm sure there's better out there, but I'm pretty satisfied with it, so far. You'll have to pay for licenses if you're profiting, but otherwise free. If you're not sure, contact them for peace of mind. I still want to revisit GitHub for Windows, again, with that GitLab "dragging URL" trick.
Git Tower looks awesome, but $70 something per seat? Ehh..
Here is what I don't know (Comment below if you have tips):
I read that .meta files are very special when it comes to Unity + versioning. Something like .... If you want, you can ONLY sync meta files, then after pull, it'll auto generate the actual files? Can anyone comment about this? I'm sure there are also pros + cons of speed.
There are still so many little files sync'd. Can anything else be added to the .gitignore?
I heard within Unity prefs you can change serialization type to force-text for easier "diff" reading (maybe it shows prefab names instead of id's). However, I heard that you shouldn't due to prefabs "detaching" and apparently taking way longer to sync/resync.
When you pull via Git, is it ok if you're still inside the project? I'd assume, like Collab, it'd just ask to refresh the scene (Unity) / code (VS).
When you push via Git, will it break things if you continue working while committing?
Any other Git[Lab] tips? Best GUI? Corrections?
TL;DR: Unity + Git requires a hefty .gitignore file, probably some hooks to sort meta files, and care to avoid all the countless mini files. GitKraken sucks, maybe one day. SmartGit is probably best "stable" GUI (imo, so far). Comment below to add!
EDIT: AWESOME comments below! Don't stop here!