Getting Good at Git Part 2 (Game Dev Day 2)
In this section we are going to go over basic commands and utilizations of Git. In the previous article we created a new repository on GitHub, now we need to learn how to make use of that repository.
First off we need to make sure we have Git Bash. Get it here if you do not https://git-scm.com/
Next up open up a new Git Bash console. It should look like this when it opens.
Keep in mind the “jrlea” is my user, so your desktop user will populate there instead.
Now lets learn some basic commands for this command line system.
First and foremost let’s learn “git — help” (that's two individual dashes)
This command will show you each individual command and what it does in a list. Use it well, use it often.
Next let’s learn how to “Change Directory”. This is a essentially the same thing as opening a folder in windows, we just do it through text instead of with the mouse.
The command for “Change Directory” is “cd”. Let’s move to the “desktop” folder now.
This is the same as doing the following in Windows!
So let’s go ahead and move into wherever we are keeping our Unity Project. I will show you two ways to do this next step.
First, we can use Git Bash to “cd” into the appropriate folder. In my case, the folder is located on my Desktop and is called “Unity Projects”.
NOTE: You can use the “Tab” key on your keyboard to auto complete commands in Git Bash. Try it out as you go!
The other way is to go to the location of your project and then right click and “Open Git Bash here”
Now onto the meat of our usage of Git. We are going to link this project (Gitting Good at Git) to our repository on Git Hub. We are going to do by using the following commands:
First off, in our project location use the command “git init”. This will initialize git in your project and allow it to communicate to the repository as we connect them in the next steps.
Next we need to copy our URL from Git Hub for the next command.
Now we will use the following command to connect to our GitHub Repository.
“git remote add origin”
The industry standard is to refer to the repository as “Origin”.
To check and make sure your connection worked we use the command
“git remote -v”
Now you are all connected!