π’π­πšπ πžπ¬ 𝐨𝐟 𝐆𝐒𝐭/π–π¨π«π€πŸπ₯𝐨𝐰

π’π­πšπ πžπ¬ 𝐨𝐟 𝐆𝐒𝐭/π–π¨π«π€πŸπ₯𝐨𝐰

Β·

2 min read

Git uses three-tier architecture refers to the three primary areas or stages that files go through in the version control workflow. These stages are the Working Directory, the Staging Area (also known as the Index), and the Repository. Here’s an overview of each stage:

β€’ 𝐖𝐨𝐫𝐀𝐒𝐧𝐠 πƒπ’π«πžπœπ­π¨π«π²
The working directory is the local file system where developers create, edit, and organize their project files. It represents the current state of the project. When you start working on a project, your files exist in the working directory.

β€’ π’π­πšπ π’π§π  π€π«πžπš (𝐈𝐧𝐝𝐞𝐱)
The staging area is an intermediate area between your working directory and the Git repository. It allows you to selectively choose which changes you want to include in your next commit. In other words, it acts as a buffer where you can review and organize your changes before making them part of the permanent Git history.

To move changes from the working directory to the staging area, you use the 𝐠𝐒𝐭 𝐚𝐝𝐝 command. This command allows you to specify which files or changes you want to include in the next commit.

Once changes are added to the staging area, they are considered β€œstaged” and are ready to be committed.

β€’ π‹π¨πœπšπ₯ π‘πžπ©π¨π¬π’π­π¨π«π²
The local repository is where Git permanently stores your committed changes. It contains a complete copy of the project history, including all branches and commits. Each developer working on a project has their own local repository.

To commit changes from the staging area to the local repository, you use the 𝐠𝐒𝐭 𝐜𝐨𝐦𝐦𝐒𝐭 command. A commit includes a unique identifier (SHA-1 hash), the author’s details, a timestamp, and a commit message describing the changes.

Commits become part of the Git repository’s history, and the HEAD points to the latest commit. The repository contains the complete history of your project, and each commit represents a specific state of the codebase.

πŸ‘‰ 𝐆𝐒𝐭 π–π¨π«π€πŸπ₯𝐨𝐰 𝐎𝐯𝐞𝐫𝐯𝐒𝐞𝐰

β€’ 𝐖𝐨𝐫𝐀𝐒𝐧𝐠 𝐨𝐧 𝐅𝐒π₯𝐞𝐬
Developers start by working on their project files in the working directory. They create, edit, and organize files as needed.

β€’ π’π­πšπ π’π§π  π‚π‘πšπ§π πžπ¬
Developers use the 𝐠𝐒𝐭 𝐚𝐝𝐝command to move specific changes or files from the working directory to the staging area. This allows for selective inclusion of changes in the next commit.

β€’ 𝐂𝐨𝐦𝐦𝐒𝐭𝐭𝐒𝐧𝐠 π‚π‘πšπ§π πžπ¬
After staging changes, developers use the 𝐠𝐒𝐭 𝐜𝐨𝐦𝐦𝐒𝐭command to create a snapshot of the changes in the staging area. Commits include a commit message that describes the changes made. The committed changes become a part of the Git repository’s history.

Did you find this article valuable?

Support Megha Sharma's Blog by becoming a sponsor. Any amount is appreciated!

Β