Unlocking Git: A Comprehensive Guide to Git Stages and Workflow

Sakeena ShaikSakeena Shaik
5 min read

Git has become the gold standard for version control, but it wasn't always the case. Before Git, teams struggled with centralized version control systems (CVCS) that limited collaboration, and early distributed version control systems (DVCS) that were complex and difficult to use. In this blog, we're diving into the evolution of Git, exploring its history, how it differs from other version control systems, and why it became a game-changer for developers worldwide.

We'll start with a quick history of Git, including why it was created and how it revolutionized the way developers work. From there, we'll examine the key differences between distributed and centralized version control systems. You'll also learn about the different stages of Git—working directory, staging area, and commit history—and how they fit into a typical Git workflow.

Whether you're new to Git or an experienced developer, this guide will give you a comprehensive look at Git's origins, its fundamental concepts, and how it can streamline your development process. Let's get started! 💻🚀

The codes developed by users are managed by software called source code Management. Source code management is of two types:
-Centralized version control system
-Distributed version control system
before the evolution of GIT, the centralized version control system was used to store the data or code developed by multiple developers.

This has a few drawbacks:
⭐️CVCS needs internet as its remote server
⭐️It is slower to update or download the code from a remote server
⭐️ It is not locally available which means you always need to be connected to a network to perform any action
⭐️Since everything is centralized, if a central server fails, you will lose entire data Example: Svn tool.

HISTORY OF GIT

GIT is a distributed version control system, that was invented by Linus Torvald in 2005. Git is a software tool. In a distributed version control system, every contributor has a local copy or clone of the main repository i.e., everyone maintains a local repository of their own which contains all the files and metadata present in the main repository. It is fast and reliable & internet connection is not required as developers work on their own local repo

Differences between CVCS and DVCS

Stages of GIT

Repository

A repository is a place where you have all your codes available or a kind of folder on the server. The repository is where Git stores the project's version history. It contains all the commits, branches, tags, and other metadata related to the project. Each developer's local repository is a complete copy of the project's history, allowing them to work independently without relying on a central server.

Server: It stores all repositories, and it contains metadata also.

Working directory:
The working directory is where developers do their work. It consists of all the files and directories in the project that are visible and editable by the developer. Changes made to files in the working directory are tracked by Git and can be staged and committed to the repository. Git doesn’t track every modified file, whenever you do commiton operation, git looks for the files present in the staging area. Only those files present in the staging area are considered for commit and not all the modified files.

Commit:
💡Stores changes in the repository, you will get one commit ID
💡 It is 40 alpha-numeric characters
💡It uses the SHA-1 checksum concept
💡 Even if you change one dot, commit-id will get a change
💡It helps you to track the changes
💡Commit is also named as SHA1 hash

Commit-ID/Version-ID/Version:
-> Reference to identify each change
->To identify who changed the file

Tags:
Tags assign a meaningful name with a specific version in the repository. Once a tag is created for a particular save, even if you create a new commit, it will not be updated.

Snapshots:
👉Represents some data from a particular period
👉It is always incremental i.e., it stores the changes (Appended data) only, not the entire copy.

Push:
Push operation copies changes from local repository instances to a remote or central repo. This is used to store the changes permanently in the git repository.

Pull:
Pull operation copies the changes from a remote repository to a local machine. The pull operation is used for synchronization between two repos

Branch:
In Git, a branch is essentially a pointer to a specific commit in the repository's commit history. It represents an independent line of development, allowing developers to work on features, bug fixes, or experiments without affecting the main codebase.
👉The product is the same, so one repository but a different task
👉Each task has one separate branch
👉Finally merges(code) to all branches
👉Useful when you want to work in parallel
👉Can create one branch on the basis of another branch
👉Changes are personal to that particular branch
👉The default branch is ‘Master’
👉The file created in the workspace will be visible in any of the branch workspaces until you commit. Once you commit, then that file belongs to that particular branch.

ADVANTAGES OF GIT:

Open Source and Community Support: Supported by a large community and extensive documentation
🌟Distributed Development: Allows developers to work offline and independently.
🌟Fast Performance: Operations are quick even with large repositories.
🌟Branching and Merging: Facilitates parallel development and easy integration of changes.
🌟Flexible Workflow: Supports various workflow models to fit project needs.
🌟Version Control: Tracks changes over time, aiding debugging and code review.
🌟Data Integrity: Ensures the integrity of project data through cryptographic hashing.
🌟Collaboration: Enables seamless collaboration among team members.
🌟Integration with Development Tools: Integrates with IDEs, CI systems, and code hosting platforms.
🌟Portability: Repositories are portable and can be easily shared and deployed.

TYPES OF REPOSITORIES:
1. Bare repository (Central repo)
Store and share only
All central repos are Bare repos
2. Non-Bare repository (Local repo)
Where you can modify the files
All local repositories are non-bare repos

HOW TO CREATE GITHUB ACCOUNT:
💎Login to https://github.com/
💎Provide username, email, and password
💎Verify account
💎Click on Join a free plan
💎You will get some questions, fill it
💎Click on complete setup
💎Go to Gmail and verify your account

"Happy Versioning! 🗂️"

0
Subscribe to my newsletter

Read articles from Sakeena Shaik directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sakeena Shaik
Sakeena Shaik

🌟 DevOps Specialist | CICD | Automation Enthusiast 🌟 I'm a passionate DevOps engineer who deeply loves automating processes and streamlining workflows. My toolkit includes industry-leading technologies such as Ansible, Docker, Kubernetes, and Argo-CD. I specialize in Continuous Integration and Continuous Deployment (CICD), ensuring smooth and efficient releases. With a strong foundation in Linux and GIT, I bring stability and scalability to every project I work on. I excel at integrating quality assurance tools like SonarQube and deploying using various technology stacks. I can handle basic Helm operations to manage configurations and deployments with confidence. I thrive in collaborative environments, where I can bring teams together to deliver robust solutions. Let's build something great together! ✨