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 -

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 the information and click Create repository button. Now we have successfully created our first repository on GitHub.

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 -

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.

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.

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.

Step 7: Commit changes

Now it is time to commit these changes. Commit is a kind of record or snapshot of what files have changed since the last time commit.

git commit -m "Update readme file"

The commit message is written in quotes. This message will be saved with the particular revision we did.

Great. So far, we have created a repository on GitHub, set up Git tool, cloned it on our local system, made changes, added changes to the staging area and committed those changes.

But our local changes are yet to be pushed to our remote repository.

Step 8: Push changes to the remote

It is time to push these changes to the server. To push the changes to remote -

git push

That is all. We have successfully pushed all our local changes to our remote repository. If we goto our remote repository which we created, we can see that change we made has been updated on GitHub.

So, now our basic work-flow is, every time we make any changes(modification, adding new files or deleting unused ones) to the local repository -

stage changes ( git add . )

) commit changes ( git commit -m "Commit message" )

) push to remote ( git push )

Note that, it is must to commit changes before pushing it to the remote server.

Let's add a few files to our local repository. (Video)

- a homepage: index.html having

- a navbar, footer, and styling: style.css

Open the project directory with your favorite code editor( I am using Visual Studio Code) -

Advance GitHub Operations

Now we are good to understand a few additional uses -