Banner for the page
0

You can use a tool called source control to track revisions to a Unity project - each change you make is uploaded to the cloud with a message that explains what you changed and who did it and you can see a log of the changes and roll back to an older version.

Source control is required for the vast majority of software development and is probably a common practice in professional 3D modelling teams. I use source control for this very website (and anyone can contribute to it!).

Git

Git is the standard for source control. You have a website (such as GitHub) which stores your Unity project and also stores each revision to each file as commits on a branch inside a repository. A repository can have any number of branches and each branch can have any number of commits. There is one branch which is very important - master - which is the "main" one that you will only probably need.

Git doesn't usually store the entire file and instead usually only stores the changes to each line however for Unity projects you have giant gigabyte 3D models so that is tricky. Git has something called LFS for this - large file storage - which we will make use of.

Install

Install Git on Windows by going to the website and download and install.

Install GitHub Desktop which has a user interface for using Git and you can login to GitHub.

LFS

You need to install LFS too. Download and install it from here.

Configuring your Unity project

Ignoring files

You need to tell Git to ignore some files that aren't useful. You do this by having a special file in the root of your Unity project called a .gitignore file. Download the file from here and place it in the root (rename it to .gitignore).

Also add in some extra rules for special Windows files because they suck. Find these rules here.

LFS

You need to tell Git that you use LFS. This is done by adding a special .gitattributes file in the root of the Unity project. Download this one and place it in the root.

Unity project

You need to configure your Unity project to work a lot better with Git:

  1. Go to Edit > Project Settings > Editor
  2. Go to Version Control / Mode and turn on “Visible Meta Files”
  3. Go to Asset Serialization / Mode and turn on “Force Text”
  4. Save the project

By doing this, the file ProjectSettings/EditorSettings.asset will be changed with these changes:

m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2

Using Git

The first thing you should do is an initial commit. This is the very first revision. I assume you use the GitHub Desktop.

  1. Open GitHub Desktop and log in with your GitHub credentials
  2. Select your repository. Create one if it does not exist.
  3. GitHub will tell you that you have heaps of files inside your project that are new. That's good. Stage them all.
  4. Click Commit. Type in a message like "initial commit". Try to be explanatory and descriptive but keep it short.
  5. Click Push. GitHub will upload your files and depending on your project it could take from 2 seconds to 1 minute.

Now you can go to the repository on the GitHub website and see your changes.

How to view an old commit

Assuming you use the GitHub Desktop client:

  1. Go to Commits and find the commit you want to rollback to. It should have a hash which is a jumble of letters and numbers - that is a unique ID for it.
  2. Click Checkout. GitHub will change your Unity project back to that revision.
  3. From Unity you should be able to build and push to VRChat as you need to. Remember you have only checked out the revision - newer revisions are still there. To replace the newer revisions go to the next section.

How to rollback to an old commit

The GitHub Desktop client is too basic for this. You need to use Command Prompt or PowerShell or Git Bash for Windows. Since you have Git installed we will use Git Bash for Windows.

You need a commit hash (ID). Follow the instructions from the previous section to get that.

  1. From Start Menu type Git Bash for Windows and launch it.
  2. From Windows Explorer when looking at your Unity project root directory, copy the path.
  3. In Git Bash for Windows type cd then paste the path. Press Enter. Git Bash for Windows should show the path.
  4. Type git checkout $hash -- . replacing $hash with the commit hash you want to rollback to. Press Enter. Git will change every file in the directory to that commit.
  5. In GitHub Desktop it should show your files have changed so now you can commit as normal.

References

Click to expand description