Git Setup and Fundamentals

Games Woods
5 min readApr 12, 2021

Preamble: As noted in my first article. I had a move planed just around the time I started this journey. Well that move has taken two weeks but it’s done. I am back to my birth-town of Montreal Quebec. We had a few glitches along the way but now it’s time to roll up my sleeves and get back on the coding horse.

Version Control Systems(VCS) have been around for over 40 years and they allow developers to go back in time to earlier versions of their code (as long as they commit and push on regular intervals!)

They are fundamental in a developers toolkit. It’s fairly easy to setup and get going. There are a few workflow “gotchas” to watch out for. But for the most part we are taking a walk down easy street.

My first VCS system was CVS and then Subversion (90’s and early 00's). Then Git and Mercurial hit and there was no looking back. The first two were centralized systems whereas Git is distributed, meaning it is perfect for teams and collaboration. For this reason it’s my favourite VCS of them all.

So now that the history lesson is out of the way let's get started with setting up Git on your system.

I’m primarily a Mac user, so the following setup will follow that path. Window’s or Linux users will find loads of articles to setup properly on those platforms. Let’s Go!

First Step… HomeBrew! I’m going down the path of total control. Homebrew is a command line package manager for Macs and Linux and allows you to easily install/upgrade tools for your computer such as Git and other system & developer tools.

  1. Open your Macs Terminal App:

2. Go to HomeBrew’s website (https://brew.sh). Click on the copy icon to the right of the code and paste that into your newly opened Terminal command line. As below.👇HomeBrew will install all the latest packages. This will take a few minutes.

3. After HomeBrew as installed you can type: git — — version. This will give you the currently installed version of Git.

4. Then type : brew install git a few minutes will pass as HomeBrew sets everything up. In some cases you may need to override Apple’s version of Git that gets installed. This article on stack overflow helped me. To check that the correct version of git is being called just type git — version again and it should show the non apple version.

5. Create new Project in Unity in your preferred Development folder structure…mine is all in Development.

6. Open up your terminal go to your projects directory eg. ~home/Development/GitterDun

7. type git init to initialize the directory as a git repo

8. Go to Github and create a new project (matching names is not 100% needed but leads to less confusion when working in teams.

9. Choose your .gitignore template as Unity

10. Add a readme if you like

11. Make it private or public based on your type of project

12. Licence type you can ignore for now. We’ll write an article about this at a later date. Now click on create repository.

13. Copy the remote server link of your newly created repo.

14. Back to your terminal window on your local machine type git remote add origin <your GitHub link>

15. Type git status and you will see the files in red that have not been added to your project …yet

16. Type git add . the period will include all files in that directory.

17. Type git status again… you should be all good! It will list all the newly added files you’ve added from the Unity project.

18. Now lets pull the files from the remote (github) Type git pull origin main (main vs master…can be confusing…you can update your terminal to use main as the default as well ..this isn’t necessary but leads to less confusion and does not create an empty branch.

18. Let’s do our first commit type: git commit -m “type your comments about this commit what you did etc”. Once you press enter it may take a few minutes for everything to get processed. Just wait till you see a clear command line again.

19. finally lets push our commit to the remote GitHub repo type: git push origin main

20. Type: git status again Yay you did it!! You’ve successfully setup your repo and synced it with the remote on github.com

Whew! this was a long one. In the next article we will dig into branches in Git along with Best Practices and flow. Git may seem daunting at first but once you get over some glitches and system/platform idiosyncrasies it becomes a valuable tool that you’ll use everyday.

--

--