This guide assumes you have basic knowledge of Unity Projects, and basic knowledge of git fork.
1.- Create Unity Project #
The first step is having a unity project created on the local machine. The type of project does not matter: The location of the project will be temporary, also its name. Both will change after synchronizing it with git.
For this tutorial I will use a unity project located in: “F:\Unity\Temp\SampleProject”
2.- Create repository #
We will go to our git hosting of choice. For this tutorial we will use GitHub. Login with our account, and create a repository. You can create a new repository directly following this link: github.com/new
In here we will need to input 3 basic things before creating the repository:
2.1.- Name #
The name for our repository, this will replace the name of our unity project.
It should not contain any special characters or spaces
2.2.- Visibility #
Choose either public or private:
- Public: Anyone on the internet can see this repository. They can download it and duplicate it. You choose who can make changes on yours.
- Private: You choose who can see and make changes to this repository.
2.3.- .gitignore #
WARNING!
Without a proper .gitignore previously added to the repository, you might not be able to upload any files.
This is the most important step, adding a .gitignore that works with unity projects. Just search the right one, and make sure it’s selected before creating the repository.
3.- Clone Repository #
Now we will clone (download) the new repository to our local computer.
For that we will need fork correctly installed, configured, and with our GitHub account.
First we need to access our repository on our git hosting.
Once in our repository, we go to the “Code” tab. In there we search for the “code” button. We will use the HTTPS method, copy the “.git” url.
Using the top left menu on Fork, we open the cloning window “File > Clone…”
In here you will paste the url into the “Repository Url:” input box. Fork will autodetect if it’s using HTTPS or SSH. You can try the connection using the “Test Connection” button. Once fork has verified that it has connection to the repository, you can choose where to save the local repository.
WARNING!
Make sure that the location where you save your repository is not inside a OneDrive or GoogleDrive folder (or similar). These services will remove files & break the repository without warning.
Once choosed a parent folder & a name, you can click “clone” and fork will start downloading the repository.
4.- Move Unity Project #
Now that we have both our unity project and our repository ready on our local machine, we will move the unity project into the local repository.
4.1.- Locate the local repository #
Firstly we locate our local repository folder.
In fork we may do that with the “Open in file explorer” button, located on the top right corner.
Once opened you should see the “.gitignore” file, and if you have the “Show hidden items” option checked, the “.git” folder.
We’ll keep this folder opened, we will use it later.
4.2.- Locate the project #
Now we will locate our unity project. Firstly we open Unity Hub, and locate the project that we want to upload to git. We right click it, or click on the three dots button on the left, and select the “Show in Explorer” button.
This should open the containing folder, we go inside our project folder to find the necessary project folders: Assets, Packages & ProjectSettings. And all the other temporary folders.
4.3.- Move the project #
Now that we have both folders open, we can move the unity project.
WARNING!
Make sure that you have closed and saved the Unity Editor and your Code Editor before continuing.
This is what it should look before moving the project. The local repository on one folder, and the project files in another.
We cut or move all the unity files into the local repository folder
4.4.- Relocate the project #
Because we have moved the project from its original place, we must relocate it. Firstly we open Unity Hub, and locate the old project. We right click it, or click on the three dots button on the left, and select the “Remove project from list” button.
Now we click on the dropdown menu right next to the “Add” or “Open” button on the top right corner, and select the “Add project from disk” option.
Now we navigate to our repository/project location, finding the folders: Assets, Packages & ProjectSettings, and click the button “Add Project”
5.- Upload Unity Project #
Now we return to Fork to upload the project.
We must do a regular commit & push:
While doing the first commit, they usually appear these folders:
WARNING!
If during this process we find an unusually large amount of files (More than 1000), or the Library folder appears. This means that the .gitignore was not correctly configured & Git won’t upload our files. It’s mandatory to add one before uploading anything.