Version control is very important when you are working on a long-term project such as game design. Here's how to set up git and start using it with Gitlab in 10 minutes or less.

 

A big thanks to David at Snopek Games for his easy to follow video guide on Git and Gitlab (shown in a Windows VM). The aim of this short tutorial is to get your git repository installed on Ubuntu Linux as quickly as possible. His series is, however, really great and easy to understand for the non-technical user. We recommend you watch his series, at least parts one and two for more information than this article will provide (such as git's gui mode: gitk). Let's get started and install git on Ubuntu Linux.

sudo add-apt-repository universe

sudo apt update

sudo apt install git

git --version

You should see a response to the latest installed version, as ours was:

git version 2.40.1

Proceed to set git by setting your username and your email address. This information is for your current machine and current user as global (assuming this is the first time setting up and there is only one group, the initial global group).

git config --global user.name "YOUR USER"

git config --global user.email ""

Review the entered data with the following command:

git config --list

This will display the information just entered:

user.name=USER
user.email=
core.editor=geany
gui.fontui=-family "Ubuntu Mono" -size 11 -weight normal -slant roman -underline 0 -overstrike 0
gui.fontdiff=-family "Ubuntu Mono" -size 11 -weight normal -slant roman -underline 0 -overstrike 0

You will notice my preferred editor is Geany and I've changed the preferred font face to Ubuntu Mono at a 11pt font size for easier reading. That can be set using the gitk package within your repo location or directly editing the file located at: /home/YOURUSERNAME/.gitconfig.

The easiest way to set the preferred editor is by using:
git config --global core.editor "geany/vim/nano/notepad++/etc"

Now we are ready to create an SSH key to use at Gitlab! Generate the key using the ed25519 encryption (don't use RSA): ssh-keygen -t ed25519 -C ""

The command will ask you to give the key a name and also to use a passphrase. You should absolutely use a passphrase. The key-ring on Linux will be put in place after the first use so there is no excusable reason not to use a highly secure passphrase.

Open up the ssh public key where you created or placed the new key pair, the easiest place is within the /home/YOURUSERNAME/.ssh folder. You may have to move your key pair if you didn't explicitly create it within this directory.

Log into your Gitlab profile and navigate to the Settings or search for the SSH keys in the search bar on the left navigation panel. If you have never set up your keys Gitlab will have a prompt to create a key, conveniently splashed at the top of your profile if you have a project created. Create a project if you don't have one already so its easy to then apply the key.

Gitlab add SSH input form

Simply enter in the information 1) copy and paste your ssh key's public information. It will have a .pub file extension and start with: ssh-ed25519 ABCDEFG... (ours start with AAAA pattern although yours might be different), 2) give the key a title and, 3) add key.

We are now ready to configure the connection from your local repo out into the cloud storage at Gitlab. You may want to note that your git email will be public and scraped by spammers. A private repo at Gitlab will not expose your email address. You can easily change the git email address by editing the config file at: /home/YOURUSERNAME/.gitconfig.

You will need to create your first repo by running various git commands within your desired project folder. Our project uses a basic GODOT tutorial demo as its project.

cd /home/YOURUSERNAME/YOURPROJECTFOLDER

git init

git status

Your git status should show on master branch and none committed. Our example here is slightly different as "up to date" because we have an pre-existing working repo. The output will be very similar but a new repo without any commits will show untracked files (this is normal):

On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean

Within your project folder you now find a new folder called .git

Its important to consider space limitations at your cloud provider. You may wish to blacklist certain file types from being uploaded to the online repo to save space especially if you are on a free tier at Gitlab. Simply create a .gitignore file or edit an existing example and you can blacklist any folder or file type with the following patterns such as

/.import/
/build/
*.blend*
*.xcf
*.ora

We are now ready to add all the project folders and files from the working project directory into git staging:

git add .

You will see a message similar as: changes to be committed ...

Use the following to actually commit the project contents. You will be prompted to add a note in the change log. If you do not add a notation and close the editor the commit will be canceled: git commit .

Now we can connect your Gitlab project. Use the following command to connect your local git repo to the remote. Please note you will have to review the Gitlab existing project push documentation for your exact project name for the command:

git remote add origin :YOURUSER/PROJECTNAME.git

Next, we perform the actual push out from your local git repo into Gitlab.

git push -u origin master

You will be asked to verify the fingerprint of Gitlab. Yes. You are likely to be asked if you wish to add your SSH key passphrase into the keyring. Yes. You will then see a processing message about Enumerating objects, compression, writing objects, to project location on Gitlab if successful.

Any further pushes may be done using:

git push

Refresh your Gitlab project page and the files you committed should appear there, now replicated from your git folder.

Lastly, to review your commits use the command:

git log

Recent logs of git actions.

Having version control guarantees you can revert back in time when mistakes or bugs are introduced into your software development lifecycle. Designers and writers can use this same system as well for peace of mind. Gitlab offers you, in some ways, a poor-man's version of a soft-cloud backup too (though that is more peace of mind in reality than anything else). We have open source solutions that can make your life easier. If you'd like us to consult your workflow and optimize your processes and websites please contact us! We are your technology experts!