GitHub Tutorial for Beginner

Iyarace Khampakdee
6 min readFeb 28, 2021

You might be wondering “what is Github?” or “why so many people use GitHub?”. Your workplace uses it. Your instructor has probably been telling you to use it. Whatever you do now a day, your path will be crossing with Git on someday.

The most basic description that I can give for Github is that it is a place for version control. It is good for working together with people but working alone is also a pretty good choice to consider using it. Can you imagine every time you update your work and you always have to the previous version secured just in case you are messing up somehow? Github is exactly that.

There will be some terminology that you might have not seen before or you have seen before but you just have no idea what it is. I am recommending you to not stressing too much about it and you will understand them as soon as you went through the tutorial. By this time, you should have a Github account so, don’t forget to sign up first.

In this tutorial, you will learn how to…

  1. Fork a git repository
  2. Creating a branch
  3. Adding a new file/Commit the changes
  4. Create a pull request
  5. Push a local file to a GitHub repository

Fork a git repository

First of all, you need a repository. You can find it online but you don’t have anything in mind you can use this link. https://github.com/EbookFoundation/free-programming-books

Locate to the top-right corner of the page and you will see the “Fork” button. (Please be clicking the work “Fork”, not the numbers behind it, or else you will be ending up on the network page.)

You will be asked where would you like to fork the repository to. If you are new there will be only one choice here which is your user name. So, go ahead and choose it.

You will notice that the name of the repository is “your username/free-programming-books”.

This is your own copy version of the free programming books repository which you can mess around as much as you want because the changes will pretty much stay here and not updating the one in “EbookFoundation/free-programming-books”.

Creating a branch

At the top-left of the Code section, there is the button said “master” which is indicating that you are in the master branch or the main branch (someplace uses “main” but they actually means the same)

There are a whole lot of branches originally in the repository. You can ignore them for now, type any name you wanted for the new branch in the box and click “Create branch: …”

And there is a new branch of your version of the repository.

Adding a new file

It can be any file and there is nothing too serious about this.

In your “new branch” that you just created, at the top-right corner, select add file and “Upload files” (you can also try “Create new file”).

You can pretty much drag and drop or choose your file.

You can write something and press Commit changes. (Notice that you can create another new branch when you add the file too but I have already had your new branch now so, there’s no need for it.)

From this point, you can locate your file in the repository to edit it. (or upload the file with the same name can also pretty much get the job done.)

Create a pull request

“Pull request” is basically a request of merging the new branch you worked on to the master branch.

In the branch that you wanted to make a pull request, select “Pull request”.

Make sure you select the base repository to be your repository even though it might send a pull request to the other’s repository.

After checking everything, press “Create pull request” on the bottom right.

In the pull request section, you will notice that the pull request is created. You can keep it like this if you wanted or press “Merge pull request” and the master branch will be updated with the new branch information and files.

Push a local file to a GitHub repository

For this task you needed…

  1. Git installed (https://git-scm.com/downloads)
  2. Create your new Github Repository
  3. Create your local folder (can just be a folder and a single text file in it)

At the top right of the page, there will be your profile. Choose Your repositories.

Select “New” to create new repository.

Name your repository and press Create repository.

You will get your repository URL. This will be used to tell where you will push the folder to.

If you installed Git, open your Git Bash

git init ~/test_repository

If you follow the path reported from the command line, you will notice that the folder you initialized is there.

cd ~/test_repository

Do not forget to change your directory to the one you created.

echo “# welcome to my repository” >> README.md

You can add anything in the folder but if not you can create just a README.md for now.

git add README.md

To track the file “README.md” to be added to the commit

git commit -m “first commit”

generate the commit with the message line “first commit”

git branch -M main

to make sure the main branch is main

git remote add origin [your repo URL.git]

to set where the committing go to

git push -u origin main

push the generated commit to the origin repo in the main branch

Once you did everything, refresh your repository webpage and you will see the change.

This is everything for this tutorial. GitHub is a very handy tool, and I wanted to introduce it to as many people as possible.

Hope you like the tutorial and please leave me some claps,

Iyarace Khampakdee

--

--