GitHub: Pull 🡆 Commit 🡆 Push

Continuing from my last Medium article, “Setting up Git & GitHub (for Unity Projects)”, we’re now moving into the 3 most important regular tasks of using GitHub:

Pulling, Committing, and Pushing:

Git Pull: “git pull” updates your current local working branch, and all of the remote tracking branches. It's a good idea to run git pull regularly on the branches you are working on locally. Without git pull”, (or the effect of it,) your local branch wouldn't have any of the updates that are present on the remote.

Git Commit: “git commit” creates a commit, which is like a snapshot of your entire repository at specific time. You should make new commits often, based around logical units of change. Commits should tell a story of the history of your repository and how it became what it is.

Git Push: “git push” uploads all local branch commits to the corresponding remote branch.

Steps to version control success

1. Pulling:

With Git Bash open and the directory set to the Unity project folder (in my case, “Version Control Example”), enter the command “git pull” to download the data from the connected GitHub repository. Now we need to specify which branch to merge the downloaded data with.

Note: Recently there was a change regarding the “master” local name. Although it still says “master” in the terminal at the end of the directory address, typing “git pull origin master” will fail with the error “fatal: Couldn’t find remote ref master”.

This is fixed by instead using “git pull origin main”. Optional: You can also use the command “git branch -m master main” to rename the remote ref of “master” to “main”, which will now show up at the end of the directory address. “git pull origin main” will work regardless of whether or not you’ve renamed it, but it’s a good reminder.

Optional: Renaming the “master” to “main”

Now, moving on. I want to pull from our remote “origin” server (which I created in “Setting up Git & GitHub (for Unity Projects)”), getting the files from the “main” branch inside “origin”, and merging with whichever local branch we’re currently on. In this case, “main”.

“FETCH_HEAD” is the most recent push/version from the online repository, so you know it is up-to-date.

Merging the pulled data from “origin” with the local “main” branch.

You can show a list of all branches using the “git branch” command.

2. Committing:

Next is to add the desired local files into the collection of files we want to commit. “git status” shows all files and folders in the directory. Red names are untracked/not added, green names are tracked/added.

Using “git status” to see all trackable files/folders

Add them individually with “git add <file/folder name>”, e.g. “git add assets”. Or add them all using “git add .”

Add all folders/files to the commit

Now we need to create the actual commit, setting the commit message to be whatever new thing I did in this commit compared to any previous commit. In this case, its the first commit after creating a new Unity project so I’ll say that.

3. Push:

Lastly, we need to push the commit to the online repository.

Pushing the commit to “origin”, the master branch of the GitHub repository we created

Now all those files are in the online repository!

That’s the whole process of Pull 🡆 Commit 🡆 Push done! Easy!



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
Vincent Taylor

Vincent Taylor


Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.