Getting Started with Git: A Beginner’s Guide

Introduction
Git is one of the most essential tools in modern software development. When working on projects, developers constantly make changes to their code. Git helps track these changes, manage different versions, and collaborate with others without confusion. This article introduces Git in a simple and beginner-friendly way.
What is Git?
Git is a distributed version control system that allows developers to track changes in their files over time. Instead of manually saving multiple copies of a project, Git records every meaningful change and stores it as a commit. Each developer has a full copy of the project history on their local machine.
How I Understand Git
When I first tried to understand Git, I thought of it like checkpoints in a video game. In a game, you don’t want to restart from the beginning every time something goes wrong. So the game creates checkpoints. If you make a mistake or lose progress, you can go back to the last checkpoint and continue from there.
Git works in a very similar way. Each time you make a commit, Git creates a checkpoint of your project at that moment. You can go back to a previous commit and restore your project to a safe state. This way of thinking made Git much easier for me to understand. Instead of being afraid of breaking things, I can experiment freely, knowing that I can always return to an earlier checkpoint.
Git Basics and Core Terminologies
Before using Git commands, it is helpful to understand a few basic terms used by Git. These concepts explain how Git keeps track of work and manages changes in a project.
Repository (Repo)
A repository is a project folder that Git monitors. It contains the project files and records every change made to them. Once a folder becomes a repository, Git starts tracking all activities inside it.
Commit
A commit is similar to saving progress in a project. When a commit is made, Git stores the current state of the files. Each commit includes a short message describing what was changed. Previous commits can be used to restore earlier versions of the project if needed.
Branch
A branch is a separate version of a project. The main branch usually contains the stable version of the code. Additional branches allow new features or changes to be developed without affecting the main branch. After testing, changes from a branch can be added back to the main branch.
HEAD
HEAD indicates the current position in the project. It points to the most recent commit on the active branch. When a new commit is created or a branch is changed, the HEAD reference updates accordingly.

How Git Branches Are Used
The diagram illustrates how a project progresses by utilizing different branches. Each branch has a clear purpose and helps keep the project organized.
Main Branch
The main branch contains the working version of the project. Only finished and tested changes are added here. The version numbers like v0.1, v0.2, and v1.0 show different released versions of the project. This branch is kept stable so the project always works properly.
Feature Branch
A feature branch is used to work on new features. This work is done separately so the main project is not affected. After the feature is completed and checked, it is added back to the project.
Develop Branch
The develop branch is where most of the work happens. New features are added here after they are completed. This branch changes often and is used to prepare the project before a new version is released.
Release Branch
A release branch is created when the project is almost ready for a new version. Only small fixes and final changes are done here. After everything is ready, the changes are added to the main branch to create a new version.
Hotfix Branch
A hotfix branch is used when there is a serious problem in the main project that needs to be fixed quickly. The fix is made and then added back to the main project and ongoing work.
Common Git Commands
Git commands help record changes and manage a project step by step. Each command has a specific purpose and is usually used in a simple order while working on a project.
git init
This command is used to start Git in a project folder. When it is run, the folder becomes a Git repository. Git then begins tracking changes made to files inside that folder. This command is usually run only once at the beginning of a project.
git status
This command shows what is happening in the project at the moment. It lists which files have been changed, which files are ready to be saved, and which files are still untracked. It helps check the project state before saving any changes.
git add
This command selects files that should be included in the next save. Files added using this command are marked as ready. Only files added with this command will be saved when a commit is made.
git commit
This command saves the selected changes to the repository. A commit records the current state of the project and stores it permanently. Each commit includes a short message that explains what was changed, making it easier to understand the project history later.
git log
This command displays a list of all saved changes. It shows previous commits along with their messages and timestamps. This helps review how the project has changed over time and allows earlier versions to be identified.




