Another path to the same woods

Photo by Yancy Min on Unsplash

In yesterday’s article, we covered the first of two workflows that I have utilized when using git with Unity. That was utilizing the Command Line Interface for git to set up our Unity project in source control. Today, we will be looking at the second of the methods, and the one that I utilize more often, which will be utilizing a GUI-based git client. As mentioned in yesterday’s article, your choice of git GUI clients is a personal one and there are several clients available including, but not limited to, GitKraken, GitHub Desktop, and SourceTree. I will be using GitKraken in these examples because it is the option I prefer.

A quick recap

First, let’s take a quick look at the steps from previous articles that we will have needed to complete. For this article’s example, we only need to have:

  1. Created a Unity Project
  2. Created a repository for the project on GitHub

Workflow #2: Using a GUI git client (GitKraken)

Today we’ll go over another workflow using GitKraken. GitKraken is a GUI-based git client that provides a more visual workflow for interacting with git. This visual workflow is the workflow I prefer, especially the drag and drop features. GitKraken can be downloaded at https://www.gitkraken.com/download

Install GitKraken

Now that we’ve covered the first few steps from yesterday, let’s GitKraken! Inward groans aside, the first thing we need to do to work with GitKraken is to install it.

  1. Navigate to https://www.gitkraken.com/download and download the client that works with your operating system.
  2. Run the downloaded installer
  3. Open GitKraken!

That’s it! You don’t even need to install git on your system like you did when working with the command-line tool. It’s all built into the program!

Initialize your local repo

  1. Open GitKraken
  2. Click the “Start a Local Repo” button
  3. Type in the folder name of the location of your project in the Name field. It is very important to follow this step closely! If you choose a path before entering the name of your project folder GitKraken tends to place a new folder inside of your project folder with your project’s name and git files. this is not what you want!
  4. Click the browse button next to the “Initialize in” field and select the folder that contains your projects folder. For example, if your project is in C:\Repos\test-repo, then you want to select C:\Repos. Once you start using GitKraken across more repositories it will remember where you created your last repo and this step becomes more of a check to make sure you are in the right folder.
  5. You can tell GitGraken what you would like your root branch to be called. It should be noted that GitKraken has already made the change from ‘master’ to ‘main’ that GitHub jas made and thus it is the default if you choose not to change it. (I still use master because that’s what I’m used to).
  6. The following steps should be left at their default. They are only useful if you are starting a new repo in an empty folder. Because we have already created our Unity project and are initializing a new repo inside of it the creation process will fail when trying to add either of these.
  7. Much like when you created your GitHub repository you have the option to have GitKraken include a .gitignore file for you and if you select to do so you can search for a Unity git ignore file. This will pull the same .gitignore file for Unity that is available from GitHub.
  8. Also like creating your GitHub repo, you can choose to include a licensing agreement and have the ability to choose from the same options available when creating the GitHub repo.
  9. You can choose to enable Git LFS (Large File Storage) by checking the box. I will not delve into this option in today’s article. I will have an entire article devoted to setting up Git LFS and why you might want to in a future article. Leave it unchecked for now.
  10. Click the Create Repository Button

This will initialize the git repo in your folder, create an initial commit that includes a basic readme file, and then add your Unity files in a work-in-progress state. You may notice that you have a very large number of files in your work in progress node, upwards of 4,000 files! Don’t panic, we still need to add a .gitignore file.

Add your .gitignore file

If you have a .gitignore file for Unity you can copy it into your project folder now so that the files that we want to be ignored will already be ignored when we make our commit. If you don’t have a .gitignore file yet you can get one from several sources online. I have included a few below:

Once you have added your .gitignore file to the root of your project folder you’ll see those 4K+ files drop down to about 27.

Link your GitHub repository to your local repository

Ok, now we need to link our remote repository with our local repository.

Hovering over the Remote tab in the panel on the left side of the interface and clicking the “+” button that appears opens a panel that gives a few options. You will notice that there are buttons across the top for most of the popular git hosting sites that we have talked about. If you have accounts with these sites you can link your account and then the interface will give you additional options that are specific to each of the listed services. We’re going to look at the URL option today and we’ll look at the GitHub option in a future article.

Add Remote Repository using URL

  1. Let’s explore adding our remote using the URL from our GitHub page first
  2. Navigate to your GitHub Repository in your web browser
  3. Copy the URL of your repository or click the clipboard icon {gif}
  4. In GitKraken, Hover over the Remote tab in the panel on the left side of the interface and click the “+” button that appears.
  5. Click on the URL tab at the top of the panel that opens
  6. Enter a name for your remote. A common practice is to call this remote “origin”.
  7. Paste or Enter your Remote URL from GitHub into the “Pull URL” input. This will also auto-populate the Push URL Input.
  8. Click the “Add Remote” Button

Commit the Projects Initial State

  1. Now we’re rocking! Let’s make sure that we have a good checkpoint commit that we can restore from if we need to!
  2. Click the “Stage all changes” button on the right-hand side of the interface. This will move the files to a staged state and is equivalent to the “git add .” command.
  3. Type a commit message in the Summary area at the bottom of the right-hand panel. Optionally, you can also add a more descriptive summary of the work included in the commit in the “Description” section.
  4. Click the “Commit changes to ## files” button

Push your commit up to the GitHub repository

  1. Showtime! All that’s left here is to click the “Push” button at the top of the interface
  2. If needed provide a name for the branch on the GitHub server. You can accept the default which should be named after your currently active branch.
  3. Click Submit and GitKraken will send your local repository and its commits to our GitHub repository.

Next Time!

That wraps up the second workflow that I utilize for getting my projects into source control! I prefer working with a GUI interface for git even though I also feel it’s important to have a decent understanding of the command line calls that are being used under the hood. Tomorrow, we’ll take a look at Using GitKraken to shorten our process by one step! We can create our GitHub repository right from within the GitKraken interface! If you enjoyed this article, or want to come along with me as I progress on my journey, follow me at gamedevchris.medium.com.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Christopher West

Christopher West

76 Followers

Unity Game Developer, Software Engineer, Gamer, Musician, and Father. Christopher is a creative that enjoys a challenge and loves coding.