Gamasutra is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
July 5, 2020
arrowPress Releases







If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 

Preparing your project for version control using SourceTree and Bitbucket

by Elmar Talibzade on 04/29/16 03:14:00 pm   Featured Blogs

1 comments Share on Twitter    RSS

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

 

Crossposted on App Goodies

At some point of game development, we all need to secure our project away from harm…

So today I am going to teach you how to add your existing work to a Bitbucket repo using SourceTree.

Before we get started, let’s get to know what version control actually is! (skip this if you already have basic understanding).

What is Version Control?

Version control (aka revision or source control) is the management of changes to documents, software, complex websites or games. Instead of making backups the traditional way (zipping the WHOLE project), version control tends to save only CHANGES of your project, which makes work faster and more efficient.

The catch is that you can always come back to that change no matter what.

So say you’re testing a new game mechanic. You make the latest commit and get to work. But a while later you realize how dumb this mechanic was. Instead of removing it from the project (hunting down scripts, placeholder models etc.) you can simply revert back to the version you were previously on, removing all changes you’ve made.

Adapted from Wikipedia

Definitions

While version control is pretty easy to understand, there are some terms you need to know:

Repository – a virtual storage where all your project files and metadata are stored

Committing – creating a commit of changes made to your project

Push – uploading commits to repository (only new commits are uploaded)

Pull – downloading commits from repository (only new commits are downloaded)

Clone – adding a repository to your program (e.g SourceTree)

You can see the whole list of terms here.

Why BitBucket?

 

Bitbucket allows you to have private unlimited repositories for free (up to 5 users). However, its main weakness is that it doesn’t allow more than 2GB of files in your repository, so if you want more space you can always use Visual Studio Online and Perforce (both are free). If you’re working on a simple mobile project then Bitbucket is a good choice!

Apart from that, Bitbucket has a free program which allows you to manage your repository with ease – SourceTree. This is what we’re going to use to commit, pull and push our changes into our repository!

Things that need to be done

  1. A BitBucket account
  2. SourceTree
  3. Dummy Project to practice on

Creating and setting up a repository

First off let’s create a repository to host our project. Go to Bitbucket > Dashboard > Create > Create Repository

Fill out the details (name, description, etc).

I would recommend choosing Git as your source control, as it feels faster than Mercurial, it may just only be me, but another reason to choose Git is because it’s more common among developers.

 

Once your repository is made go to SourceTree press “Show Hosted Repositories” button (located at the bottom left).

 

A window will pop up. Click “Edit Accounts” located at the top right.

 

Press Add. Fill your bitbucket.org account credentials and press OK.

 

Wait for the list to update. You’ll see your newly created repository! Double-click it and you’ll be given an option where to clone your repository.

 

Note: I would recommend you to clone your repository into a directory where your current project is located – just to keep things clean.

Select your desired directory where you want your repository to be. Give it a name (will be displayed in SourceTree) and press Clone.

You should see that your repository has been added to the list on the left hand side. Congrats! We have finished with our Repository!

Configuring Unity3D

Open Unity and select your project.

 

Once your project is loaded, go to Edit > Project Settings > Editor.

Set Asset Serialization Mode to “Force Text”.

Edit: Thanks to Simon (darkside) Jackson pointing out that you must make sure that Version Control Mode must be set to “Visible Meta Files”

 

Once you’re done. You can now close Unity!

Final Bits!

Locate your Unity Project and drag it to the directory your recently cloned repository is residing. It’s best if you drag Unity Project contents instead of the whole folder to avoid confusion in the future. You can now remove your original Unity project since it has already been copied to the new directory.

Before closing folder, download this Unity .gitignore file. This will enable SourceTree to ignore files with certain name extensions, which are not needed to be backed up. Put it into the root of your project like so:

 

Open the Unity and you’ll see that your Project is gone. No worries! Click “Open” and locate your new version control ready project and open it!

Congrats! Your project is now working with source control. Now let’s learn a bit more about SourceTree.

Using SourceTree

Open SourceTree. You’ll see that it has automatically detected which files has been added, modified or removed. Pretty sweet!

 

Check all unstaged items and you’ll see they’re all moved into staged items. That means these files will be included into our first commit.
Before we actually commit, enter a commit message at the bottom right. Include stuff like changes you’ve made, or bugs you have fixed etc. But since it’s our first commit, I would simply add “Initial commit”. Make sure you’re in File Status tab.

 

Finally, press Commit. This process can take several seconds to a few minutes (or even hours) depending on the size of your whole project. Another commit will depend on the size of CHANGES you’ve made to your project. Same process happens with “Pull” and “Push”.
Once you’re done you’ll be moved to the main view of SourceTree. It shows a list of all latest commits.

 

Now we need to “Push” our repository online – best place to hide your repo from unwanted fire and explosions!

Press Push > OK and wait while your project is being uploaded online. (time duration varies by project size and your internet connection).

Once it’s done it’s done! You can now see your commit in the main dashboard of your Bitbucket account.

Conclusion

Congratulations on completing this tutorial! Hope it was helpful!

Found any errors? Tutorial too confusing? Tutorial requests? Let me know in the comment section below.

If you enjoyed this article then be sure to check out my blog for more of these!


Related Jobs

innogames
innogames — Hamburg, Germany
[07.03.20]

PHP Game Developer - Grepolis
Remedy Entertainment
Remedy Entertainment — Espoo, Finland
[07.03.20]

Programmer (Character Technology team)
Square Enix Co., Ltd.
Square Enix Co., Ltd. — Tokyo, Japan
[07.03.20]

Experienced Game Developer
Remedy Entertainment
Remedy Entertainment — Helsinki, Finland
[07.01.20]

Technical Director





Loading Comments

loader image