Linking GitHub to your Local Project

Gabriel Perez
3 min readMar 21, 2021
Day 5

After creating a GitHub repo, we can now link it with our project.

Initializing Git

The first thing we need to do is to initialize Git in our project. But first, we need to head into our GitHub repo and copy the URL of the repo.

  1. In your GitHub repo directory, locate the button “Code” and copy the URL as seen on the image below.

2. Open Git Bash and navigate towards your project directory using command lines. Alternatively, you can open your explorer to locate the project directory, then right-click on the folder, and click “Git Bash Here.”

Git Bash will now hop into that location as shown below. It’s a shortcut that can save you time if your project directory is nested within your drive.

3. Next, we need to initialize Git to communicate with the GitHub repo so we can start tracking this project.

We now type in the init command line to initialize the Git repo in your project.

  • git init
In this case, it says “Reinitializing” because I have already initialized it previously, but initially, it’ll say “Initializing” instead.

Add Remote Server

4. The URL we grabbed from our GitHub repo will now be used to connect with our local project so they can both communicate with each other.

Go back to your Git Bash window, and type in:

  • git remote add origin (paste the URL here)

I have previously added a remote origin into my local project. Hence, the error about the origin already existing. But if you are starting fresh, it’ll seem like nothing happen without the error.

Oh, but something did happen! It added the version control, the origin, to our local project behind the scene.

Before we continue, we need to understand what just happen. Let's break up what “git remote add origin URL” means:

  • git- This will allow us to run Git commands.
  • remote- This will allow us to communicate with a remote server.
  • add- This will allow us to add a server
  • origin- the name of the master server. This name is industry standard. Always name your server “origin.”
  • URL- The URL address of the GitHub repo.

Verify Remote Server

5. To verify that we successfully have a connection, we type in:

  • git remote -v

We can verify that we now have permission to fetch the origin and push the origin so that we can create and pull commits.

Congratulations! We can now verify that we are linked to the server!

--

--

Gabriel Perez

Hello everyone, My name is Gabriel Perez, I am a Unity Developer and a creator who is always learning and experimenting.