[Unity | Synthetic Doc | en] Store Unity Project on Github

What is Github

GitHub is a website and cloud-based service that helps developers store and manage and share their code, as well as track and control changes to their code. Because it is a cloud-based service, you can access your project from anywhere.

There are 2 terms you may want to get familiar to understand more about Github:

  1. Git: Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
  2. Version Control: Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members.

You can visit the 2 links below to create a Github account and download the Github desktop.

Why we might need to store Unity Project on Github

There are 4 main benefits:

  1. Access your code from anywhere, and save your project from anywhere (to the cloud).
  2. Track, manage and reverse the code when you make any mistakes.
  3. Share and co-work with other developers (if you want, or keep your project private).
  4. 3 above benefits are totally FREE!

How to store Unity Project on Github

The easiest way, step-by-step instruction to make a Unity project that you can push to Github later is as the great video below. Note that now you can choose Private to keep your project secret without any charge.

The instruction in short will be:

  1. Create your Github Account.
  2. Create a repository - a folder to store your whole single unity project
    2.1. Name the repo.
    2.2. Set the repo in private or public as you want.
    2.3. Check the box Initialize this repository with a README. The README file is where you tell about your project.
    2.4. Add a .gitignore file which will tell git to not upload some specific file types or folders when you push your project to Github.
    2.5. Choose a license if you want.
  3. Download Github Desktop (you may skip this step when using Visual Studio Studio to code. Visual Studio has a menu for you to clone a repo and do other Git commands as Github Desktop)
  4. Clone the Github repo that you make in step 2.
  5. Make a new Unity project and store it inside the local repo folder that is made in step 5.
  6. In Unity Setting, set Version Control Mode to Visible Meta Files. Then, set Asset Serialization Mode to Force Text.
  7. Add a summary and commit all the change (in Github Desktop or Visual Studio).
  8. Push the change to the Github server.
  9. When you make any changes to your unity project, remember to commit and push the changes.

When you get familiar with commit changes and push the changes to Github, you may also want to improve your working workflow with more advanced features of Git:

  1. Create a branch.
  2. Merge branches.
  3. Revert previous commits when any problem happens.

Or, you may like working with Git directly in the Visual Studio without wasting time switching to Github Desktop. You can do that by installing Github Extension for Visual Studio as instructed in the video below.