What is Github?

This is gutsytechster everybody!

Well today, a large concept is waiting for us to begin with. As the title suggests, we are going to learn about Github . If you would remember, in last blog we talked about Git, learned the concept of version control. This blog is an extension to the last one. However, we’ll talk only about Github throughout the blog.

What is Github?

If you are aware of Git and version control, you must have heard about Github also. We know that Git is a distributed version control system. Github is a web based Git repository hosting service i.e. it uses Git in background to do version control. All the work that Git does can be done by Github. When I say Github, I refers to github.com. However, when I say Git, I refer to a VCS.

There are many Github like services available, e.g. bitbucket, beanstalk, gitlab, sourceforge etc. However, Github is the most popular and widely used one among them.

Let’s begin then…

Before beginning, I’ll suggest you to go through my previous blog on Git so that you already know the basic terminologies and how to work on git.

Firstly, go to the website https://www.github.com. Sign up for it and create your account by giving necessary details. It would show you a tutorial which I’ll recommend you to go through so that you would know the basic functionalities like creating repo, branching etc. You can do that any time, you find suitable. After that go to  your profile by clicking on the ‘Your profile’ option given on the dropdown menu.

github_tutorial_1

Fig. 1.

Now create a new repository by clicking on another drop down menu on the left of your profile one having ‘+’ sign:

github_tutorial_2

Fig. 2.

Let’s give it the name which we give to our Git repostory in previous blog i.e. GitLearning and a small description about it, let’s say This is for learning purpose. Let it be public and initialize it with a README. Basically a README file contains description about your repository and it is a good practice to have a README for every repo. you make. After that click on the ‘Create Repository‘.

Our next work is to create a file. To create a file click on the option “Create new file” inside your repository just below the releases option:

github_tutorial_3-e1524392076583.png

Fig. 3.

As you would be seeing , the initialization of README file is the initial commit we made. When you’ll create the new file, give your file a suitable name. Let’s say HelloWorld, then write a few lines in it as:

This is the first file in this repo.
And We are learning Github.

Once you write the text into the file go to the bottom of the page give it a commit message as “Create HelloWorld“. Then click on “Commit directly to master branch“. Finally, click on “Commit new file“. Now, you would be having two files i.e. HelloWorld and README.md file.

Now, let’s edit the file we made. I have entered a new line in it:

This is the first file in this repo.
We are learning the Github.
It uses Git as a Version Control System.

To edit,  click on the file,  On the right side, you would be seeing a pencil, click on it. Now, you would be able to edit the file. After editing, give it a suitable commit message. I am giving it “Update HelloWorld“. Then do commit changes.

Now, check the commits you have done till now. Go to the commits option as shown below inside your repository in the Code feature:

github_tutorial_4

Fig. 4.

By now, we have done three commits. When you’ll click on any of the commit you will see the ‘+’ sign before a line which represents that a  line has been added. Similarly a ‘-‘ sign represents that a line has been either modified or deleted.

Now, let’s do branching.

To create a new branch, click on the Branch option just below the commit option as you can see in the above image. Once you click on it, name the branch as NewHelloWorld. Once you click enter you will be checked into the NewHelloWorld branch automatically. Now, let’s do some changes and see if they are reflected back into the Master branch, which is the default branch.

This is the first file in this repo.
We all are learning the Github.
It uses Git as a Version Control System.

To edit the file you have to follow the same procedure as we did earlier i.e. click on the file to be edited, then click on the pencil icon, do the changes and then write commit message(here “Added all after we“) and then commit changes. Now, in this branch the no. of commits would be 4.

github_tutorial_5

Fig. 5.

We know that branching is done to test a new feature and if we find our new feature being successful, we merge it in the master branch.

If you would see in the above image, it is showing that our branch is 1 commit ahead of master branch. So, it generates a suggestion of compare and pull request.

We want to merge our branch now, so click on the option “Compare and Pull request” or you can click on the “New pull request” next to the branch dropdown menu. If everything is going the right way, you would see a message in green color i.e. Able to merge. This means that the two branches do not have any conflict and can be merged easily. Otherwise there would have appeared a message of Merging Conflict in red color. To know about how to resolve merging conflicts, kindly refer to here.

Now, give your pull request a title, description and then hit create pull request. You have created a pull request to master branch. Since both the branches are your own, so it would be showing the option of “Merge pull request“. But don’t do it from here. Go with the procedure as we did in the Git tutorial i.e. first we switch to the master branch and then we merge it. So first switch to the master branch just like earlier from branch option.

In your master branch, you would see a pull request in the option shown below next to the Code and Issues option:

github_tutorial_7

Fig. 6.

Click on the pull request which we made from the NewHelloWorld branch, and then merge it after clicking on the “Confirm merge“. Now, you can check for the changes in master branch and you will surely find them.

Since you have now merged the request, the NewHelloWorld branch can be deleted. To delete a branch, you can simply go to the branch option next to the commit option in the Code feature. There you will get the trash icon. Simply click on it to delete the branch.

Upto now whatever we did was the same which we did using git in terminal. Here we did the same things using Github. Now, we’ll see some of the other features available in Github:

  • Networks

First Go to the “Insights” option in the same series with Code and Pull Request options. Then on the sidebar on the left side, you would find an option of Network. Just click on it and there would a screen representing the network of chain of commits. If you are following it from the beginning, you will see something like this:

github_tutorial_6

Fig. 7.

When you will take your cursor to the highlighted points on the network, it would show all the commits that we have done till now.

  • Issues

Issues are the great way to keep track of tasks, enhancements and bugs for your project. You can open an issue by hitting the option “Issues” next to the Code feature. There you will find the “New issue” option. Click on it, give your issue a suitable title and description and then “Submit new issue“. When we open an issue, it means that we want others to think over our bug or enhancement or if there is any kind of help we need. This is a way of a healthy development.

You can assign labels, assignees or milestones to an issue also.

  • gh-pages

gh-pages or Github pages are public webpages hosted and easily published through Github. It provides free service to host your website. Since, it is free, so you can’t have an independent domain. Your username would be suffixed by github.io. To know more about gh-pages, you can refer here.

In the end, I would tell that git and github are two independent platforms to perform version control. However, each of them has some specific functionalities. The best way is to use both of them in a collaborative manner, which we’ll learn in upcoming blogs. If you have any query regarding this blog, feel free to write in the comment section below.

Till then, goodbye!

Be Curious!

 

Advertisements

One thought on “What is Github?

  1. Pingback: Git Github Together – Curiosity never ends

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s