Sunday, November 17, 2024
Google search engine
HomeGuest BlogsWhat is GitHub and How to Use it?

What is GitHub and How to Use it?

GitHub is one of the most well-known tools among developers. Every developer out there knows how to use GitHub one way or the other. GitHub provides an array of functionalities and boasts a supportive community to help any new developers just starting GitHub. It is a code-hosting platform where users can update codes or files and track their updates. To understand better about GitHub, it is important to understand about Version Control System and Git. 

How-to-Use-GitHub

We’ll see its components and how to use them below.

Version Control System(VCS)

It is a tool used to record any changes made in files and keeps track of any changes made in a file or folder. The most popular Version Control System (VCS) is Git and its platform, GitHub.

What is Git?

GitHub provides a version control system called Git which is used to track any updates/ commit changes performed in a user’s repository. Git can be downloaded in Windows and changes can be committed using the Git Command Prompt available in your system once you download Git. 

Must ReadGit Features

What is GitHub?

GitHub is a hosting platform used by developers to save their code online and track its changes to see what will work when it comes to them working on their projects. GitHub is popular among people in the IT industry due to its easy-to-understand UI and its ability to act as a progress tracker using a Version Control System to track changes. This enables projects to be collaborative. 

There are various reasons why developers prefer using GitHub. They are:

  • Collaborative Projects: With its existing Version Control System (Git), and the hosting abilities of GitHub on its website, it provides great room for innovation and collaboration among developers to develop collaborative projects.
  • Issue Tracker: Any grievances experienced by the developer when they use Git or GitHub can be taken with the tech support team. GitHub has specifically provided an issue tracker to every developer who uses GitHub to communicate the problems they experience while using Git or GitHub.
  • Supporting Different Languages: As a code hosting platform, GitHub provides support to a plethora of coding languages and provides support specific to that language. These codes are the base codes used to train GitHub Copilot, an AI-based code generator that autocompletes code with only a few prompts. Some of the languages they provide support to are not limited to C, C++, C#, Ruby, Java, JavaScript, HTML, Python, etc.
  • Pull Requests: In repositories, developers viewing codes can change any files that may be necessary to optimize the code or fix any errors by utilizing pull requests which directly change the root node in the main repository.
  • Hosting Code: GitHub provides a web platform where developers can host various codes for various purposes.
  • Open Source Support: GitHub, due to the reasons mentioned above is a great hub for hosting Open Source platform codes and hosting them to commit and update any updates or changes in the platform.

Git vs GitHub

Now that we’ve seen instances of both, what is the difference between Git and GitHub? Are they both the same? Can we use one without the other?

Git as mentioned earlier is a Version Control System (VCS) which is mostly used as a progress tracker to record what changes have happened to date.

GitHub is a hosting web-service platform where developers can host their codes online either in public repositories or private repositories. It can also be used as a Hub for communication. But, without Git, it isn’t possible to utilize GitHub. Each is dependent on the other.

For more details, refer to the article – Difference Between Git and GitHub

Getting Started with GitHub

There are various ways to utilize GitHub to its fullest potential properly. One way is by creating a GitHub account

The steps to create a GitHub account are shown below:

Step 1:  Go to the Website

Go to the GitHub website and click the Sign-up button.

Signup on GitHub

Step 2: Enter the details

Signup on GitHub

After entering the details, you will get a Captcha to verify whether you are human or not.

After successfully entering your details, a code will be sent to your Email and you need to fill it.

Step 3: Let GitHub know a little more about you

After entering the code, GitHub will ask a few questions to help in personalizing your account.

Once you’re done answering those questions, choose which plan you would like to use. Here, we chose the Free Trial option.

Signup on GitHub

Congratulations! Now you have created your very own GitHub account!

After creating your account you can add your name, along with social media links and add names. This is similar to customizing your profile on Instagram.

Signup on GitHub

An alternate way is by downloading the Version Control System Git in your system. The steps for the installation of Git can be found here.

Now you have an account in GitHub. After signing in to your GitHub account, let’s see how to use GitHub properly. It is a very powerful tool given to the hands of developers.

How to Use GitHub?

GitHub is a code hosting platform that can support multiple languages. Here, we’ll learn how to start with a few things, namely:

  • Working with the GitHub Dashboard.
  • Create, Update, and Delete Repositories.
  • Perform different kinds of operations on files and repositories in GitHub.
  • Clone Repositories.
  • Fork Repositories.

Here’s how the GitHub dashboard looks like

GitHub Dashboard

The Dashboard in GitHub is where you can see all the repositories you’ve created on the left-hand side. The updates from GitHub are made known to the developers on the right-hand side.

You can also view what your followers or those who you follow on GitHub are up to in the “For You” section or also get some trending news, similar to the “Trending” tab on YouTube.

The “Following” tab has a similar functionality to view what the people you follow on GitHub are up to. 

Since GitHub is a hosting platform, users can use repositories as a folder to upload files.

What is a GitHub Repository?

It has similar functionalities to a folder in a System to store various projects in different folders. As we know, GitHub is a web-hosting platform for developers, hence to properly segregate and store code, they provide the developers with the ability to store files of their projects in such repositories in which they can edit, add and delete files. If the repository is public, other platform users can notify the repository owner of any bugs by utilizing Pull requests. 

1. Create and Update Repositories on GitHub

The most important use case of GitHub is its ability as a hosting platform to store files on its website. GitHub provides developers with the tools to Create Repositories, update repositories either by editing files, or adding/deleting files. All these operations are seen in detail below. 

1.1. Using the ‘+’ button in GitHub to create a Repository

Log into your account on the GitHub webpage. Then click the “+” button. This will bring a drop-down box with some options. Click the “New Repository” button.

After clicking the button, it will redirect you to another page where you need to fill in the description and the necessary information for your repository.

It can be optional whether you want to choose your repository to be viewed publicly, that is, anyone accessing GitHub can view your repository and its contents, or it can be private, which means only you can see and access your GitHub repository.

You can type anything in the Description and tick the box next to “Add a README file” and create your repository. Once the repository is created, you can see the first file pushed (added) in your repository is the README file.

1.2. What is a README file?

A README.md file is used by developers to write a short description describing their project, or in the case of Open Source Software, they start to write a detailed description to install or use their software.

The ‘md’ in the README.md file stands for the Markdown file similar to markup languages such as HTML (HyperText Markup Language). It is used to style the README file for including code, or other things.

The concept of the README file is explained more in detail here.

The process to customize and create a repository is explained more in detail here. Once you’ve created your repository, you can start adding files according to your projects. Let’s see how we add files to our repositories. 

2. How to Add Files to Your Repository?

Again, there are three ways to add files to your repository. One is using Git Bash, then with Github webpage UI and the other uses the Git GUI. In this article, we’ll learn to add files to your repository using the GitHub webpage. 

Go into the repository and click “Add File”, which will open more options as shown below:

Here, you can either upload files present in your system or write your code in GitHub if you want to.

As seen above you have both the drag and drop and Push Requests option to be used to add or delete files in a repository.

3. How to Delete a GitHub Repository?

To delete a repository, navigate to the settings bar in the repository you want to delete.

Scroll down to the end where you will come across the “Danger Zone” and will be provided a list of options. Click “Delete Repository”.

This will bring a popup where GitHub will ask you to type the name of the repository to confirm its deletion.

Once you know how to do all of these, it is important to learn about the labels available in your GitHub repository.

4. Labels in GitHub

They are a way to provide tags for descriptive metadata available in your repository. The main functionality of Labels in GitHub is to organize push/pull requests, issues, and the different types of items available in a repository. It is also possible to create your custom label in GitHub. 

The available labels and their description can be seen by navigating to the “Issues” section and clicking “Labels” to see all available labels.

The process to create a custom GitHub label in GitHub is explained in detail here.

5. Operations in GitHub

These are common procedures that have been performed on files in GitHub repositories with varying use cases. These are used to provide platform users with the ability to change the contents of their repositories dynamically.

Some of the common operations in GitHub are:

  • Creating pull and merge requests.
  • Creating a branch.
  • Cloning a repository.
  • Forking a repository.

5.1. Pull Request or Merge Request

In GitHub, users can create a Pull Request to let the owner know that some changes have been done to their files in the repository. It can only be accepted by the owner to implement changes in their code. 

Once the Pull Request is accepted, the merge request will be performed. This is to approve the process where the changed file will be merged into the repository, committing changes to the main branch.

To know more about GitHub merge click here

Commands on Git Pull and Git Merge are shown below.

git pull origin
git merge origin/master

6. What are Branches?

The branches in GitHub allow you to experiment safely with your code. Branches provide a safe space for code experimentation and debugging processes. Branches always start from the “main” repository and branch out to sub-repositories to test specific parts of the code in different environments. This is done to not commit any changes in the main code, but if needed the branches can be committed to the root repository. 

You can add or delete branches to a repository in GitHub and it is very easy to do so. To create a branch, we need a base repository to do so.

The operations that can be done are merge commands, push commands, and pull requests.

6.1. How to create a branch?

Go to your repository and click on the “main” branch. This will create a drop-down where you can choose a name for your branch and create it.

After creating it, it can be viewed when you select “View all Branches”.

6.2. How to Delete a Branch?

To delete a branch, simply click the trash icon in the branch to delete it.

7. Cloning Repositories

GitHub offers many features such as cloning repositories. This is done to keep a copy of the repository on your desktop, and the changes you make in the Desktop files will also be reflected on the GitHub page.

7.1 How to Clone a Repository?

For the above example to clone repositories, go to the GitHub repository you’d like to clone. Go to the repository you want to clone, and click the “Code” button.

Copy the link, and to clone it, open Git Bash and type this code:

git clone <repository url>

This will clone the repository to your desktop where you can synchronize your changes on your desktop to the code on the GitHub page.

It can be found in your saved files as seen below

8. Forking a Repository

A fork is created when a new repository is created by copying a previously existing public repository to add your changes to it. These changes can be personal or you could submit a pull request to the owner of the original repository to apply these changes. 

Forking repositories are done for a few reasons:

A. Starting Point For an Idea: To create your idea for a project, you can fork an existing repository as a code base and then expand on the idea from the base code.

B. Correct Any Mistakes Present in the Project: When you notice any glaring errors or bugs in a public repository, one of the ways to effectively do it to people you do not have contact info with is:

  • Fork the repository.
  • Edit the code to remove any bugs.
  • Submit a pull request to the owner to apply these changes.

Suppose you have created a repository for a project and uploaded it publicly. Another GitHub user who you may not know, may notice your profile and check it and may find some bugs. They can suggest some changes by forking your repository and applying the changes themselves then, submit a pull request to you. This is the difference between cloning and forking repositories.

8.1. How to fork a repository?

Go to the desired repository you’d like to fork and click the “Fork” button.

Fork GitHub Repository

This will redirect you to another page where you can customize the Repository name and the description.

Github23

The “Copy to the master branch only” is to submit pull requests which may be incorporated by the repository owner and click “Create Fork”.

Now you have successfully Forked the repository.

Alternatives of GitHub For Developers

GitHub is one of the well-known VCS hosting platforms out there, but there are many more players providing services similar to GitHub in case you want to explore other alternatives. 

Some of the platforms are:

  • GitLab
  • Azure DevOps server
  • Jenkins CircleCI
  • Jira
  • Assembla
  • CloudBees

GitHub Copilot

GitHub Copilot is an AI integration by GitHub used to autocomplete codes for languages that it supports. GitHub copilot can be integrated with an IDE to generate code. It is not necessary to use a specific platform anymore. Currently, it is a paid subscription, but it is potent with the ability to generate code automatically with less than a few prompts.

It has been trained with a large number of codes available in the GitHub platform and uses Generative AI to generate its code.

Future Scope 

With its constant updates in functionality and its leaning towards a low code or no code environment for its, UI has dramatically increased user-friendliness among people from different walks of life. Right now, GitHub will only continue to upgrade its already existing functionalities and become even more popular.

Conclusion

Due to its user-friendly and versatile nature, knowledge about Git and GitHub is very valuable for many companies. Despite it being user-friendly, the sheer ability to customize almost anything, especially after the introduction of GitHub copilot has made it an attractive skill in the IT industry. It is also due to its dedicated community help in bug fixing, solving issues and so much more, that learning GitHub is a must. However, due to there being so many components to creating or removing repositories, and storing and editing code, it may be a little overwhelming for beginners who may just be starting to learn how to properly use Git and GitHub.

Last Updated :
01 Aug, 2023
Like Article
Save Article


Previous

<!–

8 Min Read | Java

–>


Next


<!–

8 Min Read | Java

–>

Share your thoughts in the comments

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments