Basics of Github and Repo Hosting

In this lesson, we’ll discuss repo hosting – how you can host your repo on a server which makes your project indestructible!

We’ll cover the following

  • What is repo hosting?
  • GitHub
    • Creating a GitHub repo from an existing Git repo
    • Creating a branch
    • Opening a pull request
    • Merging changes
  • Deploying GitHub code to a hosting platform

What is repo hosting?

As discussed in the previous lesson, Git can be used to version control your project on your local machine; however, it cannot be used to collaborate with others and does not safeguard your project if you lose your machine.

So, to ensure that your project remains accessible even if you lose your machine, you can upload your code to a server. This is called ‘repo hosting’ and many services are available for free that provide this. For example, GitHub.


Before we get into GitHub, we’re going to stress upon the fact that Git and GitHub are NOT the same! Git is a version control system, whereas GitHub is a repository hosting service! Okay, so let’s get started.

Git vs. GitHub

Creating a GitHub repo from an existing Git repo

First, sign up to GitHub. Create a free account and sign in. Then, create a new repo by clicking the + symbol and ‘new repository’ on the top right as shown below.

Then give a name to your repo and create it! Now, open up a command-line terminal and change directories to an existing Git repo. Then at the top of your GitHub repository’s Quick Setup page, click to copy the remote repository URL. It’ll look something like Then, add the URL for the remote repository like so,

git remote add origin
# Sets the new remote

And finally, push the changes in your local repository to GitHub like so:

git push -u origin master
#This is a master branch

To push the changes in your main branch like so:

git push -u origin main

Creating a branch

According to the GitHub Glossary is a “branch is a parallel version of a repository. It is contained within the repository but does not affect the primary or master branch allowing you to work freely without disrupting the “live” version.

When you’ve made the changes you want to make, you can merge your branch back into the master branch to publish your changes. For more information, see ‘About branches.’” Branches are primarily used to create new features, and they can be merged back into the master branch (the main branch) after making a pull request.

Opening a pull request

A pull request is a proposed change to the repo submitted by a user and to be reviewed and accepted or rejected by the repo’s collaborators. Pull requests have their own discussion forum.

Merging changes

Once a pull request is approved, it can be merged with the master or branch or other branches.

Have a look at the diagram below for a clearer picture!

Deploying GitHub code to a hosting platform

Now that we’ve covered some GitHub basics, you’re probably wondering about the next step: how to get the code from GitHub to the actual server(s) that host(s) your website.

Now that we have the most skills we need to start learning web development, let’s learn some basic principles of software engineering starting from the next chapter.

Also Read – Using Git Locally

That’s it!
You have successfully completed the post. Do Share : )

Peace Out!

One comment

Leave a Reply

Your email address will not be published.