- Version Control Basics
- Sourcetree installed
- Bitbucket Account created
- Unity Core Concepts (Official Unity Tutorial)
- Unity installed
- Unity account created
Step 1 – Open Sourcetree
Step 2 – Create a new repository for your project
Remember to also tick the box to create the repository on your remote account. This will let you back up your repository to the cloud on Bitbucket.
If you are using Fife College computers, remember that you must put your repository in your U drive and NOT in your Documents or Desktop folders in order for Sourcetree and Unity to work.
Step 3 – Open Unity Hub
Step 4 – Create a new Unity project
The new Unity project should be located inside your repository’s folder. You can tell it’s in the right place if the folder containing your new Unity project is next to the .git folder.
In order for something to be tracked by version control, it must be inside the repository’s folder. Nothing outside will be tracked! The repository folder is the one with the hidden .git folder inside it – remember not to put anything in the .git folder itself!
Step 5 – Add the Unity .gitignore
DEFINITION – GITIGNORE
A .gitignore file tells the version control system that it should not pay attention to certain files. This is useful for files that are generated when the game is built, or for temporary files.
This file is vital. Without it, very large temporary files will be added to your version control project every time you make a commit, and you also won’t be able to commit while Unity is open. There is no easy way to remove these files if you accidentally forget the .gitignore and commit them, either! So make sure to always remember this step.
Usually you can find .gitignore files already set up for common game libraries and engines. You can download the Unity .gitignore from the GitHub website here:
To download the file, right click anywhere on the page and select “Save As”.
Rename the file to just “.gitignore”, and select “All Files” as the file type. If you leave it as “Text Document”, Windows will unhelpfully assume you want to add a .txt to the file’s name.
This file needs to go in a very specific place – inside the Unity project folder, NOT just inside your repository folder. It should be next to the Assets, Library, and other Unity folders, NOT next to the .git folder. See the illustration below for an example.
Step 6 – Make your initial commit
Once you get a new, blank project setup, the first thing to do is always make an initial commit just saving the setup to version control. To do this, go back to Sourcetree. You should see some changed files in your repository.
If Sourcetree is not on the File Status view, remember that you can get there by choosing “File Status” or “Commit” in the top left area.
In the “Unstaged Files” section, you should see around 20 files. This will include all of your blank Unity project’s files, as well as your .gitignore file.
If you see closer to 100 files and any have long names with strings of random letters and numbers, this means there is something wrong with your .gitignore file! Go back to the previous step and check it carefully.
Once you have checked that your .gitignore is working, stage all of the files, add a commit message (something like “Created blank Unity project”), and make your commit!
Step 7 – Push to Bitbucket
With your commit made, you should now push your project up to Bitbucket. Click “Push” in the top of the window. You can check on the Bitbucket website to ensure your repository is correctly backing up the files.
- Other version control tutorials
- Unity Editor – Importing Assets