Unreal Engine 4 + GitHub First Steps

Software:
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 version 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.

Disclaimer:
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.

General Preparations:

  1. Create a GitHub account:
    github.com
    Note:
    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…)
  2. Install Git for Windows:
    gitforwindows.org
    Note:
    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.
  3. Install Git LFS:
    git-lfs.github.com
    Note:
    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).
  4. Optional: Install GitHub Desktop:
    desktop.github.com
    Note:
    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:

Note:
I’m using GitHub Desktop to initialize the repository with UE4 Git LFS settings and also
  1. Create an Unreal Engine 4 project (if you haven’t already created one..)
    Note:
    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.
  2. Important: Backup a full copy of the UE4 project somewhere safe at least for the first steps.
    Note:
    I Actually needed to use this backup to save my own project (see below)
  3. In GitHub Desktop, choose File > New repository to open the Create a new repository dialog.Annotation 2020-04-18 212957
  4. 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.Annotation 2020-04-18 213139
    Note:
    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.
    Another Note:
    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.
    Blender Note:
    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:Annotation 2020-05-29 140520

Setting up Git LFS for the new repository:

Note:
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.

  1. Open Git Bash for the new repository by right clicking its root folder background and choosing Git Bash Here:Annotation 2020-04-19 002454
  2. In the Git Bash console, write the command:
    git lfs installA
    This command sets-up Git LFS for the repository:B
  3. 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.C
    Note:
    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:E

Publishing the new repository to the GitHub server:

Note:
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:

  1. 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.Annotation 2020-04-19 012328
  2. 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.Annotation 2020-04-19 012509
  3. 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…Annotation 2020-04-19 012541
  4. Once the process of publishing the new repository has finished, we can browse the new remote repository on GitHub:Annotation 2020-04-19 013620

Regularly committing and pushing updated state of the project/repository:

Note:
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.
Steps for committing the updated state of the repository to Git and pushing it to the remote server:
  1. Commit the changes to Git:
  2. 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.Annotation 2020-04-20 232346
  3. 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.
    Note:
    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.Annotation 2020-04-20 232419
  4. 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:

Annotation 2020-04-21 222458
There is a free, open source Git client plugin for the Unreal Editor developed by Sébastien Rombauts, that ships (at beta stage) included with UE4 4.24, and has many useful features integrated into the Unreal Editor like initiating the project repository with Git LFS setting, committing project states directly from the within the Editor, comparing versions of blueprints and more.
I did some tests with the plugin and found it very convenient, however It doesn’t track changes to the projects C++ code so if your coding you’ll have to commit code changes using a different Git client.
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:

Note:
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!
Corrupted .uproject file:
After the first time I managed to get all the LFS setting right and successfuly push publish the project, strangely, it wouldn’t launch in the UE Editor, displaying the following message when I tried to double click the project .uproject file:
Untitled-1
And displaying the following message when I tried to launch it through the Epic launcher:
Untitled-2
After some inquiry I found out (to my astonishment) that some how the git operations have replaced the text contents of the .uproject file from this:
Untitled-3
To this:
Untitled-3
Luckily for me I had a full backup of the whole project before starting the setup trial and error process, so I could manually restore the .uproject file to it’s correct state and go on working.
Corruption during download from GitHub:
After a couple of successful commit and push operations with my project, I decided to test how a git repository works as backup, so I tried to download the project folder compressed to a zip file.
The extracted project would launch and compile, but fail to load the main (and only) level it had, displaying this message:
clone
Looking into this, I found that the level umap file is was actually in it’s place but drastically reduced in size:
* The left is the original
clone2
The good news:
I then tried to clone the project via git clone command, and that way it did work as expected.
That’s it!
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.
Happy Unrealing and Source Controlling! 🙂

6 thoughts on “Unreal Engine 4 + GitHub First Steps

  1. Thank you for this little walkthrough! Helped me a ton.

    I noticed an error in your .gitignore

    * Blender backup files
    *.blend1

    Should be…

    # Blender backup files
    *.blend1

    Also, the link to your existing .gitattributes file appears to be broken.

    1. Hi Chad,
      I’m really glad you found this article helpful! 🙂
      Your right about the error in the gitignore blend1 file comment, I fixed it in the post.
      The preset UE4 gitattributes file I linked has unfortunately been removed by its owner. (it’s not mine..)
      So I deleted the broken link.
      Thank you very much for commenting!

  2. Thank you for the walkthrough, wish I found it sooner, haha!
    We are a small student team who are working on a project but didn’t put a gitignore, now we already used up 80% of our data usage… 😅
    Still, was really helpful. Especially knowing about the Git Plugin. Thanks!

    1. Hi Jennifer,
      I’m glad you found this post useful! 🙂
      * I actually deleted my UE4 repos and initiated them again after learning this myself….

Leave a Reply