Dev Ops Getting started with Git and GitHub

Getting started with Git and GitHub

-

- Advertisment -

Git is a version control system that enables developers to organize their code with ease and in a safe place. You are allowed to either upload your code as open-source and public or private where only you and the people you choose can access it.

We will learn how to use it and also host our site for free on gh-pages.

What you will learn.

  1. Creating an account on git-hub.
  2. Installing git on your computer.
  3. Creating a simple one page HTML CSS website.
  4. Pushing the code to git-hub.
  5. Hosting your site on gh-pages.

Who is this tutorial for?

This tutorial is for a beginner in programming who knows some of HTML and working with the terminal. But if you don’t know, do not worry because the tutorial will take you through every step in the process. If you are an expert in git, this tutorial may include too much detail for you, so feel free to go and check out my more advanced tutorials.

Creating an account on git-hub.

Creating an account on git-hub is completely free.  Paid versions are also available on Git-Lab which has more advanced features. The free version is good enough for most projects. You can skip this step if you already have an account.

Head over to https://github.com  and proceed to create an account.

After creating the account create a repository and name it: git-github.

Copy the push URL on your repository and paste it somewhere. We will require this later in the tutorial

Installing git on your computer.

Debian Ubuntu

If you are using Debian Ubuntu open the terminal in applications or by typing Ctrl+Alt+t .

  • In the terminal type $ sudo apt-get install git and follow the prompts to install it.
  • Once the installation is done type $ git –version in your terminal to check if the installation was successful.

Windows

  • For Windows users go to https://git-scm.com/ and install git bash on your computer.
  • This will provide you with a GUI to type in your git commands.

Mac

  • Install the XCode Command Line Tools. On Mavericks (10.9) or above you can do this simply by trying to run git from the Terminal the very first time.
  • $ git –version
  • If you don’t have it installed already, it will prompt you to install it.

Creating a simple one-page HTML CSS website.

Create a folder on the desktop named git-github then in the folder create a file index.html.

On Ubuntu terminal you can type $ cd Desktop && mkdir git-github && cd git-github && touch index.html

Create 2 other files to-ignore.txt and .gitignore

The file structure should be like this

|- git-github
|	|- index.html
|	|- to-ignore.txt
|	|- .gitignore

Open the created folder in your preferred code editor e.g text editor, visual studio code, sublime text etc. I will use visual studio code.

Before you start editing open the folder in the terminal and type git init to initialize git.

On vs code, you can open the terminal simply by clicking the terminal tab on the top bar or by pressing Ctrl+Shift+`.

If success full the output should be something like this:

Copy the code below to your index.html file and save the changes.

Pushing the code to git-hub.

Once the files are saved, again open your terminal making sure the working directory i.e git-github or the name of the folder you created.

  • Type $ git add .gitignore to enable the file to be tracked by git.
  • Type $ git add . to add the rest of the files
  • Type $ git commit -m “Type here any custom commit message to help you remember the changes you made”  this will add a custom commit message to git
  • To check the changes type $ git log

Still, in the terminal type $ git remote add and paste the code you copied while creating the repository.

e.g git remote add https://techspaceke@bitbucket.org/techspaceke/git-github.git

This links our remote repository to our local git installation

  • Type git push to finally push your code. You may be prompted for your password.

The output should be something like this

Hosting the site on gh-pages.

Once the code is pushed we will go to our GitHub account and open the repository we created.

Click on the settings tab and scroll down until you see GitHub pages

On the sources drop-down, choose master.

And just like that, you have your site on GitHub.

Go to the URL displayed on your GitHub pages section to view your site. NB: this may take up to 10 minutes to be activated.

Hurrah, you are done 🙂

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Posts

Building an Exam Enrollment and Grade Notification System using Africa’s Talking SMS Shortcode API in Django

Introduction This article explores the application of SMS shortcodes to create transparency and improve the quality of education in learning...

Build a user account management system using USSD and SMS API in Go

Introduction We will be learning how to use both the Africastalking SMS and USSD api by building an application where...

Date & Time Analysis With R

One will learn how to analyse dates and time; reproducing date-related columns from a date and also format dates and time. In application, one will learn how to plot simple and multiple time series data using the R language.

Two Factor Authentication With PHP and Africa’s Talking SMS API

Two factor authentication is an additional layer of security used to ensure only authenticated users gain access to an online account. because Passwords are historically weak, and can be easily stolen, it can't alone be the way that users access their accounts.
- Advertisement -

Building a masked number system using Spring Boot, Android and Voice Apis from Africa’s Talking

Introduction In this walk through we shall be building a platform to enable a hypothetical company have their agents call...

React Native, Java Spring Boot Outbound Call Center with Africa’s Talking

Introduction Did you know you can easily create a call centre by simply integrating with Africa's Talking? You can actually...
- Advertisement -

You might also likeRELATED
Recommended to you