Git Project Quickstart
What is Git?
Git is a distributed version control system that tracks versions of files. It is often used to control source code by programmers collaboratively developing software.
How is it used differently for game engines such as Unity, Unreal, or Godot?
First, git tracks EVERYTHING from the start and it's important to establish a good workflow/pipeline, otherwise your project becomes cumbersome and difficult to maintain. Git was not designed to handle asset content, such as media (audio and videos), 3D models (FBX, OBJ, etc), textures (PNG, JPG, EXR, etc.). These files are often large in file size, greater than 100 megabytes where Git was designed to track source code files which are in kilobytes.
I recommend adding asset content, such as audio, video, 3D models, textures, etc. after the content as been FINALIZED, e.g. content has been checked in a dummy project and confirmed it has reached the final iteration and no changes will be made.
What is our Git server?
Our git server, http://10.12.15.110, is a privately hosted server located at SCiL. The software runs a custom version of GitLab, which is similar to gitlab.com. It is important to remember two things with our server:
- Your username and password is not associated with SU's credentials. Also, I recommend using the same username as your SU, which makes project collaboration easier, e.g. my username is wbrown1 out of wbrown1@su.edu
- Our server, which presents GitLab in the browser is NOT associated with GitLab.com. This means your projects hosted on our server are not on the servers with Gitlab.com
Getting Started with SCiL Git
Create an account if you have not already done so at http://10.12.15.110/users/sign_in. Sign in afterward.
Download GitHub Desktop here. Most software engineers use a variety of interfaces or even the command line for Git, but for us, GitHub Desktop is a relatively simple entry point.
If you are using a SCiL workstation, be careful about about using a browser's built-in password manager. These workstations are shared and security is handled differently by the browser vendor.
If are only copying a project using Git and not setting up a project, ensure you have GitHub Desktop installed, and proceed below to Pulling the Project
Step 1: SCiL Git Server
Get familar with the layout of the website. When you are ready, head to the dashboard and select the blue button at the top right New Project.
Select Create blank project
Give your project a name. Note the project slug gets updated.
Select your visibility level. Your visibility level and README can be changed later, if desired.
Click Create project
Step 2: Organize Project
Head to https://desktop.github.com/download/ and download and install the GitHub Desktop app.
This app is distributed by GitHub.com and although we are not using their service, it's a great and simple tool to manage our project.
This app should already be installed on the SCiL workstations. If not, we are happy to help get it installed.
After installation and providing a name and email, we need to clone our repository from the git server.
- Go to your project page. At the top right is a blue button that says Clone. Click the dropdown arrow and copy and paste the address under Clone with HTTP. You may also use the button next to the URL to copy it.
- In the GitHub Desktop app, go to File/Clone Repository. Select URL and paste in the URL you had just copied a minute ago. Before selecting Clone, acknowledge the location where this project will be saved.
-
Do not change the patch URL to your current Unity/Unreal project if you already have a project! That is for an advanced topic I am happy to cover.
- Click Clone.
- Your project folder is now initialized and we need a gitignore. Go to Repository/Repository Settings/Ignored Files. Inside this box you need to copy and paste contents from an established gitignore template, so that we don't track any garbage or cache files that get generated. Here are some samples:
- Test: You should have a new file added for your first commit! That file is your gitignore. Type in a useful message that describe your changes in the title and description fields (bottom left) and click Commit to main. This commits your changes locally only. On the header toward the top of the window, you now have an available ability to Push your changes to the server, which uploads the changes to the server as well.
You have made your first commit!
Please note: unlike services such as Google Drive, OneNote, Dropbox, files don't automatically sync in git. You have to save/commit these files as you make changes. This is necessary to avoid headaches when working with teams.
The gitignore is the most important file in your project and must be set up properly from the beginning, before uploading your project files. If you added a gitignore after committing your project files, see Wes at SCiL because the process to fix this will take some time.
Step 3: Adding the project
If you are creating a NEW project. Simply create an empty project with your game engine, anywhere BUT your git directory. Then, follow the step below.
If you may already have a project: If you do, close whichever game engine your are running and copy the folder contents (NOT the root directory itself) to your git project directory. After copy completes, open that directory in your game engine to confirm everything works.
Now open GitHub Desktop and you should see all your added files. Notice how some files are missing, intentionally, such as Library or Logs or Build if you are using Unity. These are cache files that the gitignore file is ignoring. Saving these files is useless endeavor as they are regenerated constantly, even on different machines.
When you are ready, give your changes an informative message on what changes you have made. Click Commit to main. This may take some time. Afterward, you can Push to the server, which also may take time depending on the size of your project.
Step 4: Final
Open your game engine once again and confirm everything is working properly. If it is, you may now delete your old project files or copy them to a portable hard drive as a backup (don't forget to zip first!!). If you created a dummy project to setup git, you can delete that too.
If you have any questions, feel free to visit staff at SCiL.
Pulling a Project
- Go to your project page in the server. At the top right is a blue button that says Clone. Click the dropdown arrow and copy and paste the address under Clone with HTTP. You may also use the button next to the URL to copy it.
- In the GitHub Desktop app, go to File/Clone Repository. Select URL and paste in the URL you had just copied a minute ago. Before selecting Clone, acknowledge the location where this project will be saved.
-
Do not change the patch URL to your current Unity/Unreal project if you already have a project! That is for an advanced topic I am happy to cover.
- Click Clone.