Beginners Guide to Understanding GIT

Muhammad Usama
Geek Culture
Published in
4 min readApr 11, 2021

--

Software engineering and development is growing rapidly as a successful career choice with each passing day. Millions of people are learning coding across the globe with the hopes to find a highly paid job or building their own brand. To find a good job as a software developer needs more than just writing code. GIT is one of such things. If you wanted to make a successful career out of your coding skills, Git or version control could be a huge bonus in your resume. If you want to be able to work on big projects and collaborate with teams, or developers, it's imperative to understand source control.

Understanding Source Control with GIT

Git falls under a broader concept known as “Source Control” or “Version Control”. Source Control is a management system for your code. Git is one of the tools to manage and control the versions of your code. One of the huge reasons for its popularity is that it is open source. Let’s understand it in a simple way.

Repository: Start of an organized life

The first thing before you start writing your code is to initialize a repository. A repository is made online and its copy is created on your local device. Consider it as making a folder in your computer where you will be storing your code files. So, this repository will contain all the code, files and folders linked to that particular project.

After the repository is initialized, you start writing code and save your initial code file in your local repository. At the stage of initializing, a branch is created commonly known as master branch, inside your repository. This master branch generally contains most stable version of code.

Image 1 — Initializing a Repository

Staging changes

Now whenever you add, remove or update any file, you need to tell your repository about the changes. You are in charge of what to store in the repository and what files to ignore. This part is called staging. All your code is still in your local repository i.e your laptop. So staging is meant as a set of directions for your repository. Some of the common examples of ignored components are installed dependencies or modules and sometimes multimedia files.

Image 2- Staging changes in Local Repository

Code Commit

After staging, you commit the code and that will copy the repository from your local system and store it in the cloud server according to your staging ( instructions ).

Image 3 —Code Commit

Commit History : You can literally visit past

Code Commit serves another important function. It saves the code written up till commit as a snapshot. Think of this as checkpoints in a game. But in this case, you can retrieve your code from every previous commit / checkpoint.

Image 4 — Commit history

For example, In Image 4, You can go back to any previous commit from 1 to 4 in case any bug arrived in the future. This helps a lot while resolving any issue in the code. If for any reason your code stops working, you can quickly get to the point where something went wrong.

Branches : An easy way to implement test runs

Let’s assume you have a project running smoothly. Now you want to add new features but you need them to be tested first before adding to the existing code. This is where you need branches in your repository. A branch is like a copy of the existing code.

Image 5 — Branches

While your main code is up and running smoothly from the master branch, which was created at repository initialization, your new branch ( generally named as “dev” or “development” ) will contain your new features code. After you finish developing, you can create another branch as “Quality Assurance” to test the features. Once everything is tested, you can merge your branches with master and you will have an update in your project.

Branches for different teams

You can also create different branches for different teams and merge them into one project. For example, in image 6, Three teams A,B and C are working on different parts of the same project and once Team A and C are done with their part of the code, they merge their branches with Team B’s branch which is mostly the main branch of the project.

Image 6 — Branches for different teams

Source Control: A Life Savior

Source Control not only helps you manage your code but it gives you opportunity to collaborate with developers around the world. With millions of open source projects available on github, anyone can access the code and contribute their part. It also helps developers to enhance their abilities and evolve from “just another developer” to “an outstanding developer”.

--

--

Muhammad Usama
Geek Culture

I am a tech enthusiast working with Javascript, flutter, aws, IoT and web development.