How to Create a Github Repository, Link it to your Local Project and Commit it to Version Control

Tim ‘Bear’ Sauers
3 min readOct 28, 2022

Unity Log Stardate: -300190.22773972596 (October 23, 2022, Time: 1:36:18 PM MDT)

Objective: To show the reader how to create a repository and then link your Github repo to your Local Unity Project and make a Commit to the Git.

Gitting started… Now that you have installed your git bash (for command line access) and installed git, (if it wasn’t already installed I have included the link to the instructions). At this point you will create your free GitHub account (here).

We want to open our GitBash and navigate to where your project will be on your local machine by using the change directory command “cd”.

Using GitBash, find the path to your unity project you want to connect with GitHub.
Using GitBash, find the path to your unity project you want to connect with GitHub.

As a shortcut you can also find your directory in File Explorer, right click on the directory and select “GitBash here”, this will open your directory in GitBash. An easy to use shortcut.

Using GitBash, find the path to your unity project you want to connect with GitHub.
Using GitBash, find the path to your unity project you want to connect with GitHub.

There is also creating your repository where you want it by using the “mkdir <directoryname> command.

Now that you have established your repository location, you have to tell Git, that it is in place. This is done using the git command, “git init” in the folder. Once entered Git will respond and say either “Initialized empty Git repository in <your repo’s path> c:/users/public/unity projects/gdhq version control examples/.git. If your repo already is initialized then it will say “reinitialized” instead of initialized.

Now for the 2nd Step, lets add a work file to the repo

Now we want to add a new file to our project. I started with a 3d Cube and a C# Challenge Script. Once you add a new or modified file to a folder containing a Git repo, Git will notice that the file exists inside the repo. But, Git won’t track the file until you tell it to do so.

Because Git only saves and manages files that it tracks, we need to send a command to tell Git that we do indeed want it to track our new file. Once we have created something in Unity and save the work. We can then, go back to GitBash and use the Git command “git status”. This will have Git tell us which files it knows exists.

So now Git knows we have added a file, at this point we want to “index” or “stage” the file so we can commit it. To do this we use git add <filename> or if it is several changes we can use the git add < . > (period-which means all).

Preparing untracked files for commit.
Preparing untracked files for commit.

Once the Git add command moves the files you indicated for staging (index), you can then have Git package them into a commit using the “git commit” command.

Git add to stage your new content.
Git add to stage your new content.
Reaching the staging point to utilize the “git commit” command
Reaching the staging point to utilize the “git commit” command.

git commit -m “write a description of what you created or changed” Always be specific in your description, commits live forever in a repository so if you leave a clear message of your work it is very helpful to others who might have to utilize your work later in the future.

Next Up Creating Branches and Pushing files to GitHub

--

--

Tim ‘Bear’ Sauers

At 62 I have been many things in my lifetime. I chose to learn Software Development in an effort to stay relevant for the 21st Century.