Setup Git with Unity3d for Commercial Development — Part 2 First Commit

Click Here for Part 1 — where we set up Git and GitHub, along with our first project and first Repo.

Learning the Day-To-Day Git Work Process

The initial release of Git was in 2005 so it has over 16 years of improvements and features. Gits full power can literally be someone’s full-time job to maximize.

Github’s mascot Octocat

First Some Simple Terminology

A “Commit” is saying we are backing our changes up to our Local Repo, so it’s the act of committing our changes into the Version Control System. To do a commit we first have to “Add” the changes we want to commit.

Your first Commit & Push

There are many workflows and tricks with Git to avoid potential issues or just simplify how teams work together. For now, we’re focused on learning in a solo private repo, and in later articles tackle best practices on pulling work down without losing your changes, “stashing”, and handling “merge conflicts”.

Why we need .gitIgnore

Large software projects like Unity3d projects have a lot of generated files, files we don’t really need to upload to the source control as they’d either take up space or are meant to only stay on the local computer.

How to Pull from GitHub

Pulling is pretty straight forward it’s simply this line of code

git pull origin main
Psstt if you don’t see the “.git” folder on your end that’s fine, its a hidden file for a reason

Now we can Add Changes

First, let’s understand “why” we need to add. If we use ‘git status’ we can see a lot of red lines. Red lines are all the “new” files that we have in the project, and we have to selectively define exactly what we want to add.

If you run ‘git status’ after adding but before commit it’ll show up green saying “new file”
git add .

How To Commit

Now we can Commit, there’s just one special thing we need which is our commit “message”. A message is simply a note we add to the commit so we can see what changes we put into the version control system.

git commit -m "Created a new Unity Project"

How To Push to GitHub

To push your Local Repo changes (which now contains our one new Commit), we simply need to simply say ‘git push’ but as it’s our first time we need to assign a default push location.

git push --set-upstream origin main
We can also see the time they were committed, and how many commits our project has.

Routine Commands

Now that all the setup is done it’s really just these four simple routine commands you will use throughout the day.

git pull
git add .
git commit -m "Fixed Bug #123"
git push

Congrats! You Can Now Use Git

You now know enough to start using Git daily to have a secured backup system to work on a commercial product solo.

What’s Next — LFS

If your working on a public project, or a team project, there’s lots more to learn. From dealing with licensed assets, avoiding bad merges, and automation improvements.

An Austin TX Unity3d Developer with a unique background in marketing, design, & software development leading digital web agencies to success for the past decade