Pushing Projects to GitHub and Deploy to GitHub pages

Pushing Projects to GitHub and Deploy to GitHub pages

If you've already perused my earlier blog, you likely have a grasp of what Git and GitHub entail. In this installment, I'll guide you through the process of pushing your projects to GitHub and deploying them on GitHub Pages. Let's dive in!

Prerequisites

  • Having a GitHub account.

  • installing git in your computer.

  • basic knowledge of git (read my previous blog) and command line interface.

Steps to push your project to GitHub

  • Step 1 : To create an account on GitHub and login your account.

  • Step 2 : Click on New and create a new repository.

The following image will be shown if you click on New repository:

Give the repository name and then click on create repository on the bottom right of the page.

Step 3 : On your computer, open the command line interface and navigate to the directory where your project is . You can use cd command for changing directory. Consider the image shown below.

  • Step 4 : Type in the command git init to initialize git in the project folder.

  • Step 5 : Now comes the step of selecting the files to be added on the GitHub. You can use git add . to add all the files from the project folder or you can use file name instead of . to add the specific file.

  • Step 6 : Type in git commit -m "enter your commit message" commits all your files to git (practically tells git to save a snapshot of your project).

  • Step 7 : Enter the command git remote add origin "repository URL" the URL copied from the repository. Consider the image shown below:

    This is the repository URL which you have to choose after creating the repository.

    This will connect the repository you created online with your project folder.

  • Step 8 : Execute the command git push origin master. The command line interface asks for your GitHub username and password. This last command will push your code to the repository you created online and saves it there.

If successful , you would see a message like 100% master->master.

With the above steps you have successfully pushed your project to GitHub.

Deployment of Project on GitHub Pages

To deploy your project , click on settings:

Under the setting go to GitHub pages and click on it and select master branch. Click Save . The page refreshes and gives you a URL to the deployed project. If the link does not appear then refresh the page again to obtain the link.

Note : GitHub pages is great for hosting only static websites made with HTML , CSS, JavaScript .You can push different projects on GitHub but you can use different hosting platforms like netlify or heroku to host them.