Git & Github Basics: Everything you need to know!

·

8 min read

Git & Github Basics: Everything you need to know!

Photo by Yancy Min on Unsplash

Most of us have been the end-users, or simply, users of all kinds of software all our lives. We use so many apps both on Phones & PC for all kinds of use cases. But have you ever wondered what happens on the opposite end of the spectrum? If you have, this blog is for you. Here, I intend to give you a basic idea about how the open-source community & platforms work, and where you fit in as a developer or end-user.

The intuition behind Git & GitHub

Imagine you want to make a simple to-do app on Android. You will start by learning a programming language like Kotlin/Java, and then you will learn the tools you need to make the app. Also, you will probably want to see a tutorial to understand how it's done. In short, you will follow a roadmap that will help you achieve your end goal of making the app. However, as long as you're the only one doing the project, you will have all your files stored locally on your computer (and you may also have a backup in some cloud storage for safekeeping).

Now let's imagine that you've already made and deployed your app on the Android App Store. But, since no app is perfect, you need to also take feedback from your users and keep improving the app that way. You can typically do that using the App Review system of the App Store of the respective platform.

However, what if you were told that you could allow people with the relevant skills to directly contribute to your project in some way? This is where platforms like GitHub come in. These platforms essentially allow people from anywhere in the world to contribute to your project, and help you manage & organise all those contributions in an organised and easy-to-understand manner.

Git: The Version Control System

Git, in simple terms, is a tool that we use to maintain the revision history for our project. Git maintains snapshots of your project at various points in time, so in case a new change in the code breaks the software, we can go back to a previous commit and get it back up and running. Git also keeps the code changes you make isolated from others through the use of branches when you're working in a collaborative environment.

Now let's see where the term 'version control' fits in.

Version Control: Version control systems are software that help track changes made in code over time. As a developer edits code, the version control system takes a snapshot of the files. It then saves that snapshot permanently so it can be recalled later if needed.

Git is also referred to as a 'version control' system. It implements version control in the form of commits and also allows us to access, use and contribute to the software repositories hosted in platforms like Github, in a structured manner. In short, it's a tool that allows us to interact with all kinds of open-source repositories from the convenience of our personal computers.

Github: The Code Hosting Platform

Since Git is only a tool that helps you maintain your codebase, you also need a platform where you can host your code & allow others to use and contribute to it. That's where GitHub comes in. It's a platform that allows you to host your project in the form of a repository. Once you have it hosted, others can look into it, find errors (called issues) or solve them by suggesting their changes in the form of code (via pull requests). GitHub also allows you to automate some code checks that you can use to check if some new code passes all required test cases.

GitHub isn't the only platform that allows you to host your code. There are other platforms too, like GitLab, BitBucket, etc. Many open-source software also have their own code hosting platforms.

Branches

A branch is a section where all code that has been modified by a single developer, a particular team, or related to a single topic live.

Every repository has a main branch, where the production code lives. This is the version of the code that is used by anyone who wants to use the software. So it's obvious that this code needs to remain bug-free and we can't allow everyone to push anything they want in this branch.

So what if someone else wants to contribute to the repository? In that case, they fork the repository & create their branch (or use a branch specifically designed for this purpose) to push their modified code into. This system of branching maintains isolation between multiple instances of modified code and allows the project maintainers to only commit code that is deemed fit for production use to the main branch of the repository.

Issues

An issue is an umbrella term used to describe bugs, feature additions or potential enhancements that can be made to improve the software. Issues typically have several tags associated with them, which describe their status, priority, etc. as per the requirements of the project.

Creating & describing issues is the first step taken even before the actual code modification starts. It's a way to inform the project maintainers about any current bugs the codebase has, and also any potential improvements that can be made to enhance the functionality of the software.

Here, you have the option to either work on an existing issue or create a new one. This is like the feedback system that you get on the App Stores for your app. But, in addition to just creating an issue and calling it a day, you can also work on one by creating what's known as a pull request, which we will learn about in the next section.

Pull Requests

A pull request comes into the picture just after the developer has already made the necessary modifications. Creating a PR is a way to 'request' the project maintainers to merge that code to the main branch of the repository. This is the place where you describe what changes you made in the code, what your intentions are, and what issue it's meant to solve.

After you've created a pull request, you may have to further collaborate with the project maintainers and implement any necessary changes requested by them. Once everything is complete, the maintainers will merge your modifications with the main branch of the repository.

A pull request is usually linked to an issue it's meant to fix. If you created a pull request, it doesn't mean you have to do all the work yourself. Multiple people can work together to solve a particular issue, but each of these people has to create their own pull request to do so. This is mainly done to prevent merge conflicts between all the different versions of the codebase.

Discussions

Many platforms now include a Discussion section to discuss about anything and everything! You can think of this as a place to talk about anything related to the particular project repository. Things like discussing new feature additions, getting the end user's opinion on a particular change, getting the developer community's ideas about how a particular framework migration should take place, etc. can all be done in this section.

The Use Cases

Here, I aim to highlight all the things you can do to be a part of the open-source community, developers and end-users alike.

As a Developer

Regardless of whether you have very little or a lot of coding experience, contributing to open source can prove to be highly beneficial for you. The SDLC is pretty fascinating at first glance, and contributing to open source is one of the easiest ways to familiarise yourself with the entire process.

  • You will need to read and understand all the code that is already present in the particular repository. This will help you understand which parts of the code are important, which parts are not, the file structure, and how the logic flows around the entire codebase. This knowledge and experience are very beneficial especially if you want to do anything remotely similar to developing software in your career as an IT professional.

  • You will need to have a basic idea of how the Software Development Life Cycle (SDLC) works. While most open-source projects may not be as popular as mainstream software, the basic idea is still going to be implemented in them. Ideas such as planning for a new feature, preparing a roadmap, slowly adding the feature to the existing codebase, testing the code thoroughly (using automated/manual checks) to ensure that the existing code is still functional, and finally deploying the improved version to the main branch, etc. are all things you can get a hands-on experience in. What's more, you can even become one of the codebase maintainers yourself if you want to!

As an End-user

What if you don't have any interest in going the development route but instead just want to use Free and Open Source software? Well, you can do that too.

  • You can use open-source app stores like F-Droid to download FOSS Android apps safely and securely. You will find a variety of apps here, and they even provide dedicated apps that you can install to keep your FOSS apps up-to-date.

  • In most cases, you can find instructions on how to install & use a piece of software right on the main (README.md) page of the repository. This page will include instructions on how to install it, the dependencies needed, the available configuration options, etc. You will also get a link to the official documentation if the project happens to have one.

  • Having a basic knowledge of version control is very beneficial if you want to use GNU/Linux on your computer systems. While you can get most software from the official software repositories, there will be times when you will need to use a particular software from Github. Also, there are community-maintained repositories like the AUR (Arch User Repository) which also use this same concept of version control.

Conclusion

In this blog, I've tried to cover all the basic terms and concepts that you need to understand before getting started with open source. We've learnt about both Git & GitHub and how they fit into the picture. However, as a developer, it's very important to put whatever you learnt into practice. I'll write another blog on Making Your First Open Source contribution, so stay tuned for that!

As always, have a good rest of your day and happy coding! :)