There are a lot of different options out there for using Source Control with Game Maker Studio 2, there’s even a section about it in the documentation.
Full disclaimer, I haven’t used the built in source control options, mainly due to negative feedback from forums and reddit, pointing out how their projects were destroyed by using the feature, this scared me away from it, but I still wanted to backup (and collaborate) on my games!
Initially we used cloud storage to keep our project synced between us, but this is not advisable, we were lucky enough to never have the project corrupt or to loose hours of work, but even then we were still unable to backup efficiently nor collaborate at the same time, this is where Source Control shines.
In short its a changeling where you can store every piece of code you write, and then you can access that code whenever, as well as all its passed revisions, think of it similar to a cloud version of Window’s System Restore Point or a Macs Timemachine, you can go back to prior “states” of your game.
So lets get started on using our own repositories for the use of source control, the first things we are going to need is some software, so the recommended software that you hear about the most is git & treesource as your control system, and then either GitHub or BitBucket as the place where you store your code. For this article I will be using git & Github, git has a great UI tool, especially helpful for beginners, and when I was researching this I actually started out with Bitbucket (Since I use their Trello software frequently) but after finding out that GitHub now offer free private repositories as well as bitbucket I decided to switch over.
Step 1: Signing Up
Firstly you must navigate over to your preferred software, in this case git and GitHub, so go ahead and download git, it will ask a lot of questions when installing but for the most part there’s no reason to stray from the defaults unless you know what you’re doing. Next up is creating an account with Github, from here we can now create our first repository.
Step 2: Making a Repository
First You want to his the New Button in your Repositories area, then follow that up by choosing the same settings as in the pictures below, you must give your repository a name, it can be any name you like for the most part.
Step 3: GitBash
Now that you have your accounts set up, it’s important to give your pc some credentials to allow the syncing to go smoothly and securely. So when you right click now you should have some new options, namely Git Bash & Git GUI
First we’re going to need Git Bash, you can in fact use only Git Bash and ignore Git GUI completely, but this is a beginners guide so we’ll be using the UI tool where possible. You want to type out the following two lines of commands (including quotation marks) into your gitbash one at a time, and then close it. Please replace the relevant parts with your own info:
git config --global user.email "YourEmailAddressHere" git config --global user.name "YourUserNameHere"
Step 4: Git GUI
Once you’ve closed gitbash, head over to the directory where you want your next project to be, once you find the directory, right click inside the folder.
The following screen should appear, you want to go ahead and click on “Clone Existing Repository”
Next we will need to fill in some information so that git can clone our repository.
In the order of appearance, first you must fill our the Source Location, Target directory and then the clone type settings can match the settings in the image. In the Target Directory you want to place your empty folder, and then once you’ve selected it add a new folder by typing /git or /anything at the end to create the folder that will house your code. The source is copied from your GitHub repository,
Once your repository is cloned (you will get a success message in Git GUI & you will be able to see the readme file) then its time to place your GMS2 project in the folder, then once your files are in place you’ll want to upload them to git hub. You’ll want to do this every time a significant amount of change has been made.
This is the screen you’ll be presented with, and it’s very easy to use. First the top right red box labelled unstated changes will show you everything git sees that it doesn’t see on GitHub, you must move them into staged changes below or simply click the Stage Changed button to move them all. Then you will choose push, write your commit comment so you can easily identify what stage your project was in during this time and finally you will press commit. Once successful it’ll have uploaded all your project files safely, there if you ever need them incase anything happens to your local machine!
Step 5: Fetching Updates
If you’ve gotten this far then well done, you’ve completed all the essential steps, there are a few more snippet of info I’d like to share, mainly the branch system and how to fetch updates.
Fetching Updates is easy, you simply repeat the step in Step 4 where you right click inside the repository to bring up Git GUI, then at the top select the remote tab and then fetch updates, this is how you can download changes that may have been done from a different machine. (If you’re anything like me, you probably develop on an entire host of different devices, platforms & OS).
Lastly lets quickly explain branches, a branch is individual line of development, if you’re planning on adding a new huge feature, a branch may be a good idea, especially when collaborating, you can spend time on your features, test them out and work in peace without the worry that others are unable to work, since it allows multiple devs to work on the same project don’t forget to fetch for updates and most importantly don’t forget to merge your branch back into the Master once fully operation and tested! It is not advisable for multiple devs to work on the same feature or objects within GMS2 using this method as it may cause conflicts.
Notice: Image of me provided by: https://connahwmphotography.com