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.
Top comments (0)