Day 5: Making A Commit To Your GitHub Project

What are the proper steps when making a commit?

Objective: Make your first commit to your version controlled project.

At this point we’ve verified that our GitHub and our Unity Project are connected. The next couple of steps are simple to follow but complicated to understand for a first-timer so I’ll attempt to simplify as much as possible.

There is an easy set of steps that you must remember any time you wish to commit a change. “Pull, Commit, Push”. Always in that order otherwise you might cause errors and build issues within the project. Simply sticking to “Pull, Commit, Push” will help prevent problems.

With that in mind, the command/code that you want to type first is “git pull”. This will access the GitHub and “pull” from there. However, you also need to tell it where to pull from. “origin main” tells Git that we’re looking for the repository we named origin, and the main branch. The “FETCH_HEAD” simply refers to the front.

And now if you’d like to verify which branch you’re on while listing other available branches, you can type the “git branch” command/code. If one of the branches listed (in this instance only one) has an asterisk (*) next to it then this is your currently active branch.

Now to see what actually needs to be committed. For this you need to use “git status” which will show you the things that need to be committed. In this instance the “Assets” folder is one of the folders that needs to be added. So the follow up command/code is “git add Assets/”.

You can also type “git add .” to add all of the needed commits. And just to be sure we got everything we can “git status” again to ensure this step is finished up.

We still need to add a message with the commit. You should always add a message with your commits. The command/code for this is “git commit -m” and inside quotation marks, insert your message which should reference what you were doing.

So we’ve done “Pull and Commit” but still need to “Push”. So the next command/code needed is “git push origin main”. Which will push the commit to GitHub. And if you visit or refresh your Repository on GitHub you can see the new commit.

--

--

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