In this post I will outline the process of creating a GIT repository on Bitbucket service and SourceTree for the GUI. I have used bitbucket for several years now and have always loved it since it gives the option of creating private repositories with a free account. It is not absolutely neccessay to use bitbucket / sourcetree to follow this tutorial for the most part. The principles of the tutorial can be applied to any version control.
The first thing that we will need to do is set up the repository on bitbucket. For those who might be completely new to source control, a repository is the project that is stored on the server. In our case we will be using bitbucket cloud for hosting the git repository.
You can create a free account with atlassian which will give you access to bitbucket. Once you have created an account with bitbucket, you can start creating the repository.
Start by clicking the + icon on the left panel of the website and select the repository option. This will bring up the following dialog.
This is where you enter a name for the repository and can choose to make the repository private or public. Once you have entered all the details click on the Create Repository button.
Once the repository has been successfully created, you should see the following page:
Here the important piece of information is the link to the repository. You will get two type of links to the repo – a SSH link and a HTTPS link. For the purpose of this tutorial we will only get into the https link method. Make a note of the https link, we will need this in the next step when we clone the repository.
The process of cloning the repo will create a copy of the hosted folders and files in the repo on your local machine. This copy is called workspace. You would typically work on your copy of the file from the repo and then send it to the server. To start with the cloning process, lets open SourceTree and create a new tab.
In the new tab we can select the clone option on the top options bar.
The first text box needs the link to our repo. We can use the link that was generated by bitbucket in the previous step for this. The second textbox is the path to your local folder where you would like to create the workspace. The thrid textbox is the name of the repository. This will be used to identify the workspace in SourceTree.
After filling all the required information, click on the Clone button to start the cloning process. Once this process is completed you must be able to find a .Git folder in the folder that you selected for your workspace. This folder might be hidden on your system.
Lets start by creating a new unreal c++ project. This post will not go into the details of creating a unreal project. The only thing to note in the project creation stage is make sure that the project is created inside the workspace folder. Once the project is created the folder structure would look something like the following:
The folders and files that are highlighted in red are not required to be on source control. Making sure that the project is closed in Unreal editor as well as Visual Studio, We can delete the files and folders shown.
Commit The Project:
Lets start by opening SourceTree and make sure that the right workspace is opened up. Once we have this, open the terminal by clicking on the terminal icon on the top right options bar in SourceTree. This will open up a terminal window at the workspace location.
Enter the command:
git commit -m "Project Created" -a
This will commit your changes with a message “Project Created”. once the process is successfully completed, enter the command:
git push -u origin master
This command will upload the changes to the repository on the server.
Ignore Unwanted Folders and Files:
After the push is completed we now have the commit on the server. The next step is to ignore the folders and files that are not needed on the repo. First lets re-create the folders and files that we deleted earlier.
In the workspace directory, select the uproject file and right click on it. You should get the following context menu:
Click on the Generate Visual Studio project Files option. Once the process is completed, you should find avisual studio .sln file created in the folder. Open this solution file and build the solution.
After the build process is successfully completed, open the uproject file. Once the project is successfully launched, we can close the Unreal editor and the visual stuio windows. Opening SourceTree, would show us the folders and files in the workspace that were created. We can start ignoring them as shown below:
After all the folders and the solution file is ignored. We will need to commit and push the ignore file.
That is it. We have now completed the creation of the repository, created the unreal project and added the right folders and files to the repo. We can now use the repository to work on the project. If you would like to get the project folder to see how it was setup in the repository you can get it from the tag “Repo_Created“.
There is a lot of documentation on the right way to use GIT and how it can help to make the life of a programmer easier and more organised. It also makes working and collaborating with other programmers, artists and / or designers more productive and hassel free.