GitHub is used by 31 Million developers worldwide. If you are working on a private or open source project GitHub always comes handy to keep tracks of your work. GitHub uses Git for version control. In this GitHub tutorial you will see basic git commands.

Table of Contents – GitHub Tutorial

  1. Account creation
  2. Creating repository
  3. Publishing work

Git is a version-control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source-code management in software development, but it can be used to keep track of changes in any set of files.


Now if you are wondering what is version control, it is what you do to manage changes in your program or document. In this article we will focus on GitHub basics — creating repository on GitHub, doing your stuff on your computer and uploading the changes to GitHub.

Account creation

As you can see this part hear includes information about creating a GitHub account. If you already have an account you can skip this part and proceed to creating repository. However, if you wish to create account please follow these instructions,

  • At first, please go to,
  • You may create account from the landing page at GitHub. You can also go to the account creation page by clicking up Sign up. Make sure to verify your email after you create an account.

Now that you have an account you are good to go.

Creating repository

  • First of all, please login with your credentials if you have not already,
  • After that, on the homepage you will see some buttons like NewNew repository and Start a project, please click any of them to create a new repository,
  • Now, please write down a name for the repository and write a short description of what is the repository about. For example,
Create repository at github - GitHub Tutorial - Learn GitHub Basics with S M Mahmudul Hasan |
Repository creation at GitHub

Note: While naming something we follow some simple techniques to make the names better. Like if you name something myfirstrepo, writing it myFirstRepo (Camel case notation) will make it easier to read. You can also go with this — my_first_repo (Snake case notation) format. 

  • Here comes privacy. This is the part where you decide whether the repository will be public or private. Please choose the option you want,
GitHub Repository creation image 2 - Learn GitHub Basics with S M Mahmudul Hasan |
Repository privacy settings at GitHub
  • This part here asking whether you want to add a readme file to your repository. GitHub usually asks readme for every repository created. Basically readme is where you want to tell the user what your project about, configuration, requirement and other things. You can check the option if you want to create a readme. If you do, a simple readme file will be created using the repository description which you will be able edit anytime.
GitHub repository creation - Learn GitHub Basics with S M Mahmudul Hasan |
Initializing a readme file to the repo at GitHub
  • There’s another two option you will see below the readme setting. First one is to add a .gitignore. In case you are wondering what is .gitignore,

.gitignore tells git which files (or patterns) it should ignore. It’s usually used to avoid committing transient files from your working directory that aren’t useful to other collaborators, such as compilation products, temporary files IDE create etc.

According to Mureinik’s answer on Stack Overflow
  • Another one is license, you can include an open source license in your repository to make it easier for other people to contribute. If you wish to learn more about licensing a repository, I suggest you take a look at this GitHub help article.
GitHub repository creation - Learn GitHub Basics with S M Mahmudul Hasan }
Configuring repository at GitHub
  • At the end, click on Create repository .

You have successfully created a repository. Time to look whats inside 🎁.

# Publish your work

Now that you have created a repository let’s publish something there. But before that please download and install Git on your computer and configure it executing these git commands on command prompt/terminal,

git config --global <your_github_username>
git config --global <your_github_email>

Recommended read: How to Install Git on Linux, Mac or Windows

Now let’s get publish our codes to GitHub,

  1. At first please create a directory/folder in your local machine,
  2. Now please open terminal or command prompt in the directory,
  3. After that please execute git init to initialize an empty repository in that directory to initialize an empty repository in that directory.
  4. Now you will have to tell git where to store these files of your local machine – your GitHub repository. To do that, please execute git remote add origin<your_username>/<repository_name>.git
  5. After that please create a / some files that you want to push (store) in the repository.
  6. Now in the terminal or command prompt execute git add filename.ext to add the file to staging area. For multiple files, git add file1name.ext file2name.ext and to add all the files of the directory to staging area, execute git add .
  7. After that please execute git push origin master to push the code from staging area to github repository.
  8. That’s all! Check your repository and you will see the update.

 Recommended read: Understanding the GitHub flow

Note: Here we are pushing to master because it is the main branch and which is automatically created in the process of creating a repository. If we had another branch and we needed to add things to that branch, we could have executed,

git push origin <branch_name>

Recommended read: Creating and deleting branches within your repository

Now, let’s say you have edited a file through GitHub’s website in your repository, you didn’t edit in your local machine and pushed it to GitHub repository like we did. Then if you try to push file(s) from your local machine like the way above, repository won’t accept it! Because the branch or your local machine and the GitHub repository are not equal. To make this right you will have to execute,

git pull origin <branch_name>

This will fetch repository from GitHub and will remove possible conflicts. But sometimes if the two branches that have no common base by default then you will have to add --allow-unrelated-histories flag to the pull command to force the merge. For example,

git pull origin <branch_name> --allow-unrelated-histories

The git commands shown in this GitHub tutorial are very basic and ‘all time needed’ type of commands. But there are plenty of command you need to know if you want to master git. For example, git status, git branch and so on. Take a look at the GitHub cheat sheet to learn these commands.

Don’t forgot to share your thoughts on the discussion page of this post! Also check my other writings.

Happy coding!

Disclaimer: Featured image used in this article is from

Recommended: WordPress Tutorial For Beginners 2019 WordPress is a free software, a CMS that lets you publish very easily on the Internet. Read WordPress Tutorial For Beginners to learn WordPress very easily.