As we all know, if you aren’t using version control in your software projects you are probably doing something wrong. Unity Projects are no exception to this rule. In this article I will cover basic Unity Git Setup using only GitHub desktop.
GitHub Desktop is an application that simplifies the Git pipeline with an easy to understand visual environment. It works with repositories from both GitHub and Bitbucket. It is important to note that, though GitHub Desktop may be easier to use in some ways than Git Bash or Git GUI, the user still needs to have a basic understanding of Git and version control.
I highly recommend learning basic command line Git before jumping into using GitHub Desktop. Basic Git knowledge and the ability to navigate either Git Bash on Windows or the macOS terminal are skills that every serious computer science professional should learn. If you need to brush up visit this website: The Missing Semester of Your CS Education · the missing semester of your cs education (mit.edu).
So lets get started with GitHub Desktop. After you have installed it and logged in to your GitHub page go ahead and create a new repository from the Repository Menu up top:
The menu is pretty straightforward. A note though, be careful with the standard Unity Git Ignore that GitHub provides. Make sure to modify it to suit your project. A good start for a Git Ignore can be found here: https://github.com/github/gitignore/blob/master/Unity.gitignore
Once the repository is created, you will see the main GitHub Desktop screen:
Now, jump into Unity Hub and create your new project.
Make sure, for location, you choose the directory where you created your Git Repository.
Once the project is created and the editor loads the sample scene you should see some changes in GitHub desktop:
On the left panel you will see all the changes that have been made in the project. The green plus on the side indicates that these are new additions to the project. In addition to the green plus you can see an orange looking dot, indicating a file has been modified, and a red minus, indicating a file has been removed.
All that is needed to make your initial commit is to add a comment (above you will see Initial Commit as the comment) below the changes panel and click on the “Commit to Main” button.
After that you are all set. Branches can be created and checked out out under the Branch menu. Also, when you are ready to push your changes up to GitHub click on the publish repository button in the upper right section of the screen. This will update the remote repository.
And that’s all there is to it. GitHub desktop, if you understand Git, can be a good tool to use in your projects.