Bio Photo-Edit2.png

Hello!

Welcome to my blog. I document my adventures in game development and travel.

Setting Up a Git Repository for Unity Projects

Setting Up a Git Repository for Unity Projects

This is a quick guide from start to finish for setting up a Git repository for Unity projects.

Step 1: Create Git Repository

Go to Github’s website at https://github.com/ and click on Start a project

StartaProject.PNG

Another way to accomplish this is to go to the top right tool bar drop down and go to Your repositories

YourRepositories.PNG

When in your repositories click on New

NewRepository.PNG

After doing this you are brought to a Create a new repository page.

CreateNewRepository.PNG

Fill in the information as needed and chose whether it will be public or private. On the free version of Github a private repository only supports up to three people. Keep this in mind with your projects team size.

Lastly and more important do not initialize the repository with a README or .gitignore file. Github supports a .gitignore file for Unity but more robust .gitignore files have been created online like the one I have linked below.

https://github.com/github/gitignore/blob/master/Unity.gitignore

Remember that .gitignore files need to be customized to each projects unique needs. This .gitignore file is just a great starting point.

Another reason we do not want to create a .gitignore file here is so that when we commit the Unity project files the .gitignore file will be in the directory to ignore the proper files.

Step 2: Setup Unity for External Version Control

Create your project in Unity or Open an existing one. In unity go to Project Settings and go to Editor (Edit => Project Settings => Editor). In this menu set Version Control Mode to Visible Meta Files and set Asset Serialization to Force Text.

ProjectSettings.PNG

Now close Unity and open the project directory. Delete the Library folder in the project directory and re-open Unity to re-build the project. After this the project is ready to committed to the previously created repository.

If you want to read more about using unity with external version control check out the Unity Manual

Step 3: Create New Repository on the Command Line and Push Files

This guide assumes that you have installed Git onto your computer. If not find the files here and a quick setup guide here.

At this point make sure to add the .gitignore file to the project directory. Now open Git in this directory. In the command window type.

git init

This initializes the current directory as a git repository.

git add *

This stages all the files in the current directory to be committed. There should be a message about the files being ignored by the .gitignore file. Just give it time to complete.

git commit -m “first commit”

This will commit all the stages files to the repository

git remote add origin https://github.com/<username>/<repositoryname>

This line will be unique to your repository. Adding a remote links the local git repository to the remote repository online. You can find the url you need on the github repository page.

Finally it is time to push the committed changes

git push -u origin master

And that is it! The project is now in a Github Repository.

I may make a post later on the Git work flow but for now please check out this link on it

https://nvie.com/posts/a-successful-git-branching-model/

I also recommend using Sourcetree to handle the Git workflow. It is a free Git GUI that is easy to use and useful for visually seeing the Git workflow.

Global Game Jam 2019!

Global Game Jam 2019!

Project Update #2

Project Update #2