GitHub

What is GitHub? Definition, Functions and How to Use

GitHub is one of the must-have platforms for developers because it offers an easy way to manage code on projects. This platform is quite popular with more than 56 million users from all over the world. 

Well, if you also want to use GitHub, it’s important to first learn what GitHub is. So it’s easier for you to manage your project code and make good use of all its features.

In this article, you’ll learn the ins and outs of GitHub in depth. So, let’s watch to the end!

Understanding GitHub

Github interface

GitHub is a website used to store and manage project code. You can generate or upload your code to a GitHub server and then code it online.

This is possible because GitHub is built on two main systems, namely version control and Git .

Version control is a system that records all code changes to the project. This system is important so that you can see all the history of code changes.

Meanwhile, Git is a distributed version control that makes code change history accessible to everyone in the project. It’s not just the creator of the code like in ordinary version control .

Actually, Git can only be used via the command line so it is not very friendly for beginners. However, with GitHub, you can use Git through an easy-to-understand user interface (UI).

So, what code can you manage on GitHub? GitHub itself supports quite a number of popular programming languages ​​such as C++, Java, PHP, and Python.

Interestingly, you can use GitHub for free to create unlimited projects .

However, if you want to get additional features such as better security and direct support from the GitHub team, a paid version is also available with prices starting at $4 per person/month.

Now that you know what GitHub is, it’s time to learn what GitHub does.

What is Git?

Git is a distributed version control system, meaning all codebase and code history will be available on every developer’s computer for easy branching and merging. Git was developed by Linus Torvalds in 2005, and is the core or heart of GitHub.

What is Version Control System?

version control system  is a system that records changes made to files so that all of their history is recorded and can be viewed later. When developers create new projects, they are and will continually update the code. Even after the project is online, the developer still has to update the version, fix bugs, add new features, and so on.

Version control systems help developers track changes they make to the codebase. Not only that, this system also records who made changes and recovers  code that has been deleted or modified.

Since Git keeps multiple copies of the code in the repository, no code is overwritten.

What are Hubs?

If Git is the heart, then the Hub is the soul of GitHub. GitHub’s Hub system serves to turn the  command line  , like Git, into the largest social media network for developers.

In addition to contributing to certain projects, GitHub also allows users to communicate with people who share a common vision and mission. You can even  follow  them and see the projects they are working on or even find out who they are connected to.

Repository

A repository or repo is a project file storage directory. Here, you can save anything related to the project you are creating, such as a code, image, or audio file. Repo itself is housed in the storage or storage GitHub or a local repository on your computer.

Branch

Branch is a copy of the repository. You can use a branch when you will do a development or development separately.

The work or tasks you do on a branch will not affect the central repository or other branches. When development is complete, you can merge the current branch into another branch as well as the central repository by using a pull request .

Pull Request

A pull request is when you inform the user that you’ve moved the changes you made on the branch to the master repository . The repository collaborator will accept or reject the pull request. As soon as the pull request is received, you can discuss and review the project with collaborators.

Here are some steps to create a pull request on GitHub:

  1. Go to the repository and look for the branch menu .
  2. In the branch menu , select the branch where your commits are stored .
  3. Click the New pull request option next to the branch menu .
  4. Enter the title and description of the pull request.
  5. Click the Create pull request option .

Forking Repository

Forking repository means that you create a new project based on an existing repository. In simpler terms, forking a repo means that you copy an existing repository, then make some changes you need, then save the latest version as a new repository, and make it your own project.

This feature will improve and enhance the development of the project you are doing. Since the forked project is new, nothing will happen in the central repository. You can also apply changes to the master repository in the current forking.

Here are two steps for forking a GitHub repository:

  1. Locate the repository you want to forking .
  2. Click the Fork option .

GitHub Functions

GitHub Code

Here are some GitHub functions for developers:

1. Facilitate Project Collaboration

The main function of Github is to facilitate collaboration in running projects. 

With distributed version control , all developers or team members can access and manage code in one place. For example, conducting joint code reviews, discussing bug fixes, and so on.

In addition, GitHub also provides project management features in the form of a kanban board like Trello. This feature is certainly very useful for those of you who have many projects. Because, you can more easily determine work priorities, manage workflows , and see project progress .

2. Preventing Code Changes That Could Break the Original Code

Are you afraid that your code changes will break the original code? Don’t worry, GitHub has the solution for you.

With the Branch feature , you can create “branches” from the project’s main code. So, you can make changes to the code without affecting the main code directly. Very useful when you want to fix a bug or try to add a new feature.

Now, after you are sure the changes are successful, you can immediately merge the branch into the main code. Practical, right?

3. As a Portfolio for Developers

The last function of GitHub is as a portfolio for developers. 

On GitHub, you can set the project or code you’re working on to be publicly displayed. This will demonstrate your abilities as a professional.

That way, potential clients or targeted companies can immediately see your work and contributions to various projects according to your expertise.

How to Use GitHub

Before you start learning how to use GitHub, you need to know some terms that you will often find on GitHub:

TermExplanation
RepositoryThe directory or folder that contains your project’s code change files and history. 
CommitA historical record of changes to your files, including who, what, and when the changes occurred.
CloneA copy of the repository on your computer for offline editing on your device.
forkCopy someone else’s repository to your GitHub account. Usually used to experiment on a project that you find interesting.
RemoteHere is the repository version stored on the GitHub server. You can sync with the clone version so offline changes are recorded.
BranchBranch from your main repository. On the branch, the code you tamper with will have no effect on the main repository. So you can freely experiment or fix bugs here.
MergeMerge code that has been changed on one branch to another repository. So, after you’ve experimented with the code on the branch, you can immediately add it to the main repository with a merge.
pull requestsPropose a change to the repository to the project owner/leader. Then, he has the right to accept or reject the proposal.
IssueSuggestions, questions, or requests related to the repository. Can be created by your team members or everyone (for public repositories).

Here’s a quick guide on how to use GitHub that you can practice right away:

1. Create a GitHub Account

First, visit the GitHub website at www.github.com, then click Sign Up to create a new account. 

Then, enter the required information, such as email, password, and username.

If you want to get the latest GitHub news to your email, type . Otherwise, you type .

Next, you have to do a short puzzle or Captcha as a verification step. Then, click Create Account .

Then, you will be asked to enter a verification code sent to your email. So, check your inbox or spam on your email. If the GitHub email hasn’t arrived yet, you can click Resend the code to resend the code.

After entering the code, you can go through the process of personalizing your account. If you don’t want to do that, click Skip , and you’ll be taken to the GitHub dashboard.

2. Starting a New Project 

To start a new project on GitHub, you must first create a repository. You can create a repository by clicking the button next to your profile, then clicking New Repository .

Then, you are required to enter detailed information regarding the repository. The following is an explanation of each column:

  • Repository name : the name of your repository. We recommend that you use a name that is simple and easy to remember. For example, ProjectPerdana2021. 
  • Description : a description or description of your repository. You can fill it with your goal of creating this repository. 
  • Repository type : There are two options, namely Public and Private . Public means that other people can see your repository. While Private only you can access it. You just set it according to the needs of the project.

When you have filled in all the fields, click Create Repository .

3. Create a Code File

After the repository is created, you can now create code files according to your project needs. To create a new file, click on creating a new file as shown below:

After that, enter the name and file extension according to the programming language used. For example, index.php if using the PHP language. 

Then, you can directly code in the column below. When you have finished coding, you can click Commit New File to save the file on GitHub.

The following is an example of how the index.php file has been successfully stored in your repository:

4. Editing the Code File

Once your file is saved, you can also change the code in it. The trick, you click the file to be edited and click the pencil icon like this:

For example, we will change the text “Hello World!” becomes “Hello Guys!”

After that, don’t forget to enter a description of the changes you made in the description column below. Then, select the option Create a new branch for this commit and start a pull request to create a new branch of this code. Give it a simple name, for example Index.php-revision-1 . Then, click on Propose changes .

The next step, click Create pull request to continue the change process.

After that, GitHub will tell you whether the changes match the main code. If there are no problems, you can directly click Merge pull request to merge the changes into the main code.

If the merge is successful, you will see a notification like this:

5. Collaboration with Developers or Other Projects

The previous example is using your private/private repository. Then, what if you want to collaborate?

Well, in addition to collaborating with your own team, you can also collaborate with the developer of an open-source project, you know. 

The trick, you just need to find the project’s GitHub page. For example, we are trying to collaborate with WordPress. Then, click Fork at the top right of the project page to copy the repository to your GitHub account.

Ready to Use GitHub?

GitHub is a website that makes it easy for you to manage your code online. Both personally and when collaborating with other developers.

GitHub’s feature is that it makes it easy for you to quickly develop your project while keeping an eye on the code changes you’ve made to avoid problems.

How to use GitHub is quite easy as described above:

  • Creating a GitHub account
  • Starting a new project in a repository
  • Create and edit project files
  • Collaborate on various open-source projects 

With GitHub, you can also create a portfolio as a developer with public projects. However, of course it’s still lacking without the support of a portfolio website, yes. 

A portfolio website gives you the freedom of customization such as design and features, and is unique thanks to the use of your own domain name.