What is GitHub?

GitHub is a Git repository(repository, in short, is termed as a repo) hosting service platform allowing us to store our local repositories and share it with others for collaboration.

Github is home to 28 million active developers and 85 million repositories.

GitHub makes it a lot easier for individuals and teams to use Git for version control and collaboration. GitHub repositories are open for all making the other developers collaborate.

GitHub is free to use for public and open-source projects. On January 7, 2019, GitHub announced unlimited free private repositories.

Public repositories can be seen and cloned by anyone. But no one can change or alter source repositories(called master branch) unless we provide them special permission to do so. So, there is nothing to worry as it is completely safe.

One thing that beginners tend to get confused is Git vs GitHub?

Git is a self-sufficient tool to manage source code revision history and GitHub is a hosting service for Git repositories.

We can use Git to manage our project revisions without using GitHub. But if we want to share the project with our team or to make it publically available for fellow developers, we host it to an online service provider like GitHub or Bitbucket.

How do I use GitHub?

GitHub is user-friendly and very easy to get started with. All we need to understand the terms like fork, clone, pull requests, etc.

Let's learn how to use GitHub - 

Step 1: Sign up for GitHub

GitHub is free. All we need to navigate to GitHub and create an account.

Step 2: Create our first repository on GitHub

Now we will create our very first repository on GitHub. 

- navigate to + icon and select New Repository option -

Create our first repository on GitHub

It will open a new page asking about repository information like Repository name, description and whether we want to make our project private or public, etc.

fill-GitHub-repository-info-form

Fill the information and click Create repository button. Now we have successfully created our first repository on GitHub.

creating-first-GitHub-repository

Neat. As we can see we have our first repository on GitHub ready to grow as we work.

Step 3: Install and set up Git

I have created a detailed tutorial on how to use Git. If you are not familiar with Git uses and work-flow, it is recommended to read it first.

Here is quick Git setup needed to get started -

Download Git - Depending on your operating system download Git and follow the installation window.

Right-click and select Git Bash option to initialize Git inside the project folder - 

Select Git Bash here

Set email - 

git config --global user.email "your-email@example.com"

Set name - 

git config --global user.name "Your Name"

 

Step 4: Clone the remote repository

Now we will clone the remote repository to our local system. This is because we will be working on our local repository and pushing the change to GitHub repository very frequently.

Navigate to the Github and click on Clone or Download button. It will open a dropdown with our remote repository address.

 Clone the remote repository

Navigate to the location where you want to clone the repo. Right click and select -> Git Bash option

To clone the repo we execute the below command - 

git clone <remote_repo_address>

 So we will be running -

git clone https://github.com/YOUR_USERNAME/test-repo.git

This will make a copy of the remote repository to our system. 

Do not forget to replace YOUR_USERNAME with your GitHub username.

Now we are ready to work with this repository freely and make required changes. Let's see how do we do it.

Step 5: Make changes to files

Let's start by updating our README.md file. Open it with your favorite editor and make the changes. I update the content inside the README.md file.

Update readme.md

Step 6: Add changes to the staging area

Now it is time to track changes and stage them. To check the status we run - 

git status

Let's add the changes to the staging area by running the git add . command -

git add .
 

Now if again run git status command, we see the newly created file has been tracked.