Part 1: What is Git and What’s inside it

vishnu vardhan
5 min readJun 7, 2024

--

An GIT visualizer image with basic branch name and routes

Alright, imagine you’re working on a massive program with other engineers, like building a complex website. You all write different pages, or different parts of the code, but things can get messy soon or less if you don’t track changes.

Git comes in as your secret weapon for keeping things organized. Here’s how it helps:

  • Version Control: Git tracks every change you make to the code, like a time machine for your project. You can see exactly what happened at any point, who made what edits, and even revert back to an earlier version if needed.
  • Collaboration: With Git, multiple engineers can work on different parts of the code simultaneously. It creates a separate copy (called a branch) for each person, so you don’t accidentally overwrite someone else’s work. When everyone’s done, Git helps you seamlessly merge the changes back together.
  • Experimentation: Think of Git branches like test kitchens for your code. You can try out new features or bug fixes in a branch without affecting the main project. If it works, you merge it in. If not, you simply discard the branch without affecting anything else.
  • Sharing and Backup: Git lets you share your code with others easily. You can push your code to a central repository (like a secure online storage) where everyone on the team can access it. This also acts as a backup in case something happens to your local machine.

Here’s a bonus: Git is like a digital notebook for your code. You can add comments explaining what changes you made, making it easier for you and others to understand the project’s history.

Learning Git might seem complex at first, but it’s a powerful skill that will make your life as a software engineer much smoother. Lets delve deep into GIT.

Concepts of GIT:

  1. Repository
  2. Branching
  3. Staging
  4. Commits
  5. Pushing
  6. Merging
  7. Stashing
  8. Rebasing
  9. Reverting
  10. Cloning
  11. Remote repository

Repository:

Git repository is basically a project, and technically a central storage location for managing and tracking changes in files and directories. It is a crucial component of the Git version control system, which enables collaborative development and allows multiple developers to work on a project simultaneously.

Branching:

Branching is an essential feature of Git, and it is one of the important principle and functionality that makes it such a popular version control system. By using branching, developers can work more efficiently and productively, and they can be more confident in the quality of their code.

Such branching of 3 types:

  1. Feature branching,
  2. Bug-fix branching, and
  3. Release branching

Staging:

Staging in Git is the process of selecting the changes that you want to include in your next commit. You can add files, or specific changes within files, to the staging area. Staging simply means that we are started tracking all the code changes that we are making in our application.

Commits:

Commits are the core building block units of a Git project timeline. Commits can be thought of as snapshots or milestones along the timeline of a Git project. And we can create more than 1 commit and save it in git database.

Pushing:

Pushing in Git is the process of uploading local repository content to a remote repository. Pushing is an essential part of the Git workflow. It’s how you share your changes with other developers and keep your remote repository up-to-date.

Merging:

Merging in Git is the process of combining two or more branches into a single branch. This is typically done when you want to integrate changes from one branch into another, such as when you are working on a feature branch and want to merge your changes into the main or master branch whichever is root.

Stashing:

The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy. And you can add them back at any time into any branch. And its a one time process where you cannot stash back more than one time.

Rebasing:

Rebasing in Git is the process of moving or combining a sequence of commits onto a new base commit. This can be useful for several reasons, such as:

  • To keep your local branch up-to-date with the latest changes from the remote branch.
  • To resolve merge conflicts.
  • To create a more linear and organized commit history.

Revert:

Git revert is a command that allows you to undo a specific commit in your repository. This is useful if you have made a mistake in a commit or if you need to roll back a change that you have made. This will create a new commit that undoes the changes made in the specified commit. The new commit will be placed after the commit that you are reverting. Git revert is a powerful tool that can be used to undo mistakes and roll back changes. However, it is important to use it carefully.

Cloning:

In Git, the term “clone” refers to creating a copy of a repository. When you clone a repository, you are essentially creating a local copy of the remote repository. This allows you to work on the project offline and make changes without affecting the original repository.

Remote Repository:

Local repositories reside on the computers of team members. In contrast, remote repositories are hosted on a server that is sitting somewhere around the world. This enables accessibility for all team members and promotes work from anywhere.

That is the way how git is powerfull. And makes every developers life easy and hassel free. And GIT is fully packed with CLI Tools and commands.

Claps are appreciated if in case you like the content.

Follow me for Part 2: Collection of necessary Git commands.

--

--

vishnu vardhan

Senior Software Engineer | HCL | React | Node | SQL | NoSQL | AWS | HTTP