Unreal Engine 4.24 | Git for Windows | Git LFS | GitHub Desktop
What is this all about?
A game development project is in fact a software development project, and therefore requires Source Control (aka “Version Control”).
A Source Control solution is a software system that registers and stores states of the code as it develops, and allows the developers to manage the changes, compare different versions of the project, revert to previous versions and much more.
There are more than one popular Source Control solutions in the market.
This article is written specifically about setting-up Source Control for an Unreal Engine 4 project using Git Source Control software, focusing on working with the GitHub desktop client app for Windows.
Although I’ve already had some experience using Git Source Control,
This is the first time I’ve had to set it up for myself by myself from scratch specifically for UE4 (using Git LFS), So this article can’t be regarded as an authoritative guide to the subject.
This is simply an informative record of the steps taken, problems encountered, notes, etc.
Hopefully, this post will be helpful, and if you find mistakes, inaccuracies, or that I forgot some steps, I’ll be grateful if you’ll post a comment.
- Create a GitHub account:
The installations of the Git client tools in the next steps will require your GitHub login credentials (I don’t remember exactly which and when, because I didn’t document every step being busy getting things to work…)
- Install Git for Windows:
With the installation of Git for windows we not only get the Git Client software, responsible for performing all the Source Control operations, but also Git Bash which is (in my opinion) a very convenient command-line console specialized for Git operations.
- Install Git LFS:
The Git LFS client is responsible for compressing and uploading the large binary files, which is to simply say, the files that are not ascii text format like software source code files / scripts / meta-data / settings etc., but typically media files like 3D models, graphic files, audio and the like.
We generally don’t have to do anything directly with the Git LFS client, The Git Client automatically runs it, and it operates according settings written in text files placed at the Git repository root folder (more detail on this below).
- Optional: Install GitHub Desktop:
This is an optional desktop Git client with a GUI for performing git operations.
You can do everything without it, but its convenient, and was specifically helpful for me with setting up a UE4 repository, because it provides preset Git LFS settings (more on that below).
Steps for setting up a UE4 project GitHub repository:
- Create an Unreal Engine 4 project (if you haven’t already created one..)
If you want the 3D assets, texture files, etc. to be tracked and version controlled as an integral part of the UE4 project, add a “Raw_Content” or “Raw_Assets” folder inside the UE4 project folder to store them in their editable formats prior to being imported to the Unreal project.
Uploading such large binary files to git requires using Git LFS as described below.
- Important: Backup a full copy of the UE4 project somewhere safe at least for the first steps.
I Actually needed to use this backup to save my own project (see below)
- In GitHub Desktop, choose File > New repository to open the Create a new repository dialog.
- A. In the Name field Type the exact name of the UE4 project (The name of it’s root folder).
B. Write a short description of your project in the Description field.
C. Set the Local path to the folder containing the your project folder, not the project folder itself.
D. In the Git ignore drop-down select the UnrealEngine Option.
E. Press the Create repository button.
Stage D is very important, it creates an initial .gitignore file with specific settings for a UE4 project, namely what files and folders to track and upload. a UE4 project generates massive files that are needed to run the game but are redundant, because they can always be generated again. these files shouldn’t be tracked or uploaded, and without proper settings in the .gitignore file, you wont be able to push (upload) the repository to the remote server.
This is one of GitHub Desktop’s advantages, that it offers these Git Ignore presets.
We could “Publish” the repository to to GitHub server at this stage (see explanation below).
But the reason I don’t recommend performing this action at this stage is that for a UE4 project to be successfully uploaded (“pushed”) to the remote server, we must have proper Git LFS settings, which we haven’t finished to set up prior to that.
If you work with Blender and it’s setup to save the *.blend1 backup files, it’s recommended to add this type of file to the Git Ignore file like this:
Setting up Git LFS for the new repository:
Git LFS (Large File Storage) is necessary for tracking and uploading large binary files like 3D models, texture files, audio, etc.
Depending on the size of your project, you may need to upgrade the LFS storage capacity of your GitHub account.
- Open Git Bash for the new repository by right clicking its root folder background and choosing Git Bash Here:
- In the Git Bash console, write the command:
git lfs install
This command sets-up Git LFS for the repository:
- For every type of binary file that you want to be tracked and uploaded by Git LFS,
Type the command:
git lfs track *.<file type extension>
To add this file type to the list of files tracked by Git LFS:
* This list is stored in the text file named “.gitattributes” that was automatically created in the project folder when the repository was initiated.
You can at any time type the command:
git lfs track
to display a list of the file types being tracked.
You can open the .gitattributes file and see the list.
This is an example of the LFS track list for one of my UE4 projects:
Publishing the new repository to the GitHub server:
This step includes initiating the remote repository on the GitHub server, setting it as the local repository’s origin, verifying it and pushing (uploading) the current state of the local repository to the remote one.
GitHub desktop let’s us perform all these actions at ones with it’s Publish repository button.
If you wish to know how to perform these operations without using GitHub desktop, this article gives detailed explanations.
Steps for publishing the new repository with GitHub desktop:
- Commit the recent changes (Git LFS settings we just set):
In Github desktop (assuming the repository we just initiated is selected in the Current repository drop-down), in the Changes pane, observe the list of latest changes to the repository. it should include the changed .gitattributes file, and maybe more changes.
In the Description field, type a short description of the changes like “Updated Git LFS settings” for example, and press the Commit to master button to commit the updated state of the repository to the source control history.
- Publish the repository:
The next actions will both initiate a remote repository on the GitHub server, set it up as the origin of the local repository, and push (upload) the the local repository to the server.
In GitHub desktop, make sure the new repository is selected in the Current repository drop-down and press the Publish repository button to open the Publish repository dialog.
- In the Publish repository dialog, name the remote repository (AFAIK it doesn’t have to be the exact name as your local repository’s root folder’s name, but it’s convenient if it is..), Type a description for the project, check weather it should be public or private and press the Publish repository button.
The repository’s remote origin will now be initiated, and the local repository’s state and commit history will be pushed (uploaded) to the server to update the origin.
* Depending on the size of your local repository, this may take some time…
- Once the process of publishing the new repository has finished, we can browse the new remote repository on GitHub:
Regularly committing and pushing updated state of the project/repository:
You might want to commit an updated state of your project to source control at the end of a day’s work to back it up, or when some specific development goal has been reached, or prior to some significant change, or maybe in-order for other team members/users to be able to get the latest version of the project. there could be many reasons for committing the current state of the project to Git, but the most important reason is that you want to be able to restore the current state of the project In the future.
- Commit the changes to Git:
- In Github desktop select the repository of your project in the Current repository drop-down, observe the list of latest changes to the repository in the Changes pane, where you can highlight a changed file and see on the right the actual change in code it represents. un-check changes you don’t want to commit.
In the Description field, type a short description of update, and press the Commit to master button to commit the updated state of the repository to the source control history.
- After the latest changes have been committed, you’l see the new committed state appear in the History pane, with an upwards arrow icon indicating it hasn’t been pushed to the server yet.
Highlight the top committed state and press the Push origin button to update the remote repository on the GitHub server.
When the repository wasn’t yet initiated on the remote server,
The same button that now has the title Push origin had the title Publish repository.
- While committing changes to source control for version management and backup is the basic usage of Git, there are many more source control operations that can be performed, like reverting to past commits (states) of the repository, opening new branches for to manage different version of the project, merging branches etc. to name just a few examples. these operations are beyond the scope of this article, and I strongly recommend to get to know them and more.
Unreal Editor Git Plugin:
It may be that I just didn’t understand how use the plugin or set it up to track C++ code. I didn’t to find out if it officially doesn’t support this. however, if you work heavily with Blueprints It should be very useful.
Some issues I encountered:
I don’t know if these issues happen frequently, the reason may very well be me not doing things correctly.
There may be simple solutions to these issues that I don’t know about..
What’s absolutely certain is:
When you’s about to start your first steps with source control on a real project, make sure you back it up first!
* The left is the original
I hope you’ll find this article useful or even time/error saving.
If you find anything unclear, inaccurate or missing, I’ll be grateful if you leave a comment.