The first Pull, Commit, and Push with Git!

Frank Warman
5 min readMar 22, 2021

Alright, now we’re getting somewhere! We successfully hooked up our Unity project to the remote server on GitHub, but now it’s time to actually get our local files onto the server as well.

This method will become second-hand nature. You’ll constantly be updating branches, keeping your project nice and organized, and you’ll feel a weight off your shoulders every time you do. It’s time to execute our first Pull, Commit, and Push!

First open up Git Bash in your project directory as mentioned in previous articles. Assuming you are using the project we just set-up, things will be ready to make a “pull” request from the GitHub server.

Do this by typing, “git pull origin main”:

Previously, Git had used ‘master’ as the main branch (hence why it’s the selected current branch -light blue), and kept it for older projects. The new naming convention is ‘main’ for your main branch (why ‘git pull origin master’ did not work.
  • git pull — downloads content from a remote repository and immediately updates the local repository to match that content
  • origin — is the remote repository (GitHub server) where the info is being pulled from.
  • main — is the branch that the info is coming from within the server.

It is very IMPORTANT to note, that when working with more than just yourself, git pull commands are essential to the workflow! You want to be working on the latest version of a branch, and not your local one from a couple days ago. Remember to ALWAYS pull, commit, then push!

Update 2023:

In the recent years since the writing of these articles, the IT community as a whole has decided to move away from certain offensive terminology. To this end GitHub no longer uses ‘Master’ as the default name for the primary branch of a repository. You can use the following command in GitBash to correct the default naming in git.

git config — global init.defaultBranch main

And if your current repository has a the Master branch, you can use the following to fix it.

git branch -m master main

This section is now null and void as per the previous sections commands, but I will keep it here for posterity…

So, in the caption of the above picture, I mentioned that the naming convention is now ‘main’ instead of ‘master’. Yet the current branch is still (master) → light blue. This does not bode well for me when I’m looking through Git Bash! It straight up irks me.

To remedy this, I quickly create another branch called main and switch over to it. To create a new branch you type “git branch <name>”. Name will be ‘main’ in this instance.

Then I double check the branch was created by typing “git branch”. The ‘master’ branch is still selected as you can see it highlighted in green. To switch branches, you simply type “git switch <destination branch>” (‘main’).

One last double check to make sure we’re on the right branch. You can see it highlighted green, and also in light blue at the end of our command line:

Now that we know we’re on our main branch, that is adequately named, it’s time to make out first commit!

First, we’ll check to see what changes in our local file do not match the pull request we just made. To do this, we type “git status”:

This is telling us that the Assets, Packages, and ProjectSettings files are not in the main branch.

We can stage them for the commit by typing “git add .” — the period denotes everything being added that is currently not tracked.

Typing “git status” again will show you every file that has now been added to the staging queue:

Now that the files are staged to be committed. We can use the command “git commit -m “(message)”.

When making commits, a message is warranted to keep your commits organized (-m “ “). It is best practice to state exactly what happened in this commit, to easily go back through your project should any problems/bugs arise. For the purpose of this first commit “Created new Unity Project” is perfect.

The git commit command only commits to your local branches. You will not be able to interact with these online, yet. Pushing your local commit to the remote server will complete the process!

We do this by typing “git push origin main”:

Now, you’re Unity Project and files are available on your GitHub server! Head over to your online repository and you should see something similar to this:

Congratulations! You’ve successfully created a Unity Project, integrated with Git through Git Bash, connected to a remote server, and pulled, committed, and pushed you local files to the server!

You’re well on your way now to becoming a Git master!

--

--

Frank Warman

Audio Engineer turned Unity Game Dev. Will be combining both my skillsets when appropriate, and will be documenting my Unity Dev growth in these Medium Articles