DEV Community

Cover image for ๐’๐ญ๐š๐ ๐ž๐ฌ ๐จ๐Ÿ ๐†๐ข๐ญ/๐–๐จ๐ซ๐ค๐Ÿ๐ฅ๐จ๐ฐ
Megha Sharma
Megha Sharma

Posted on

๐’๐ญ๐š๐ ๐ž๐ฌ ๐จ๐Ÿ ๐†๐ข๐ญ/๐–๐จ๐ซ๐ค๐Ÿ๐ฅ๐จ๐ฐ

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:

Image description

โ€ข ๐–๐จ๐ซ๐ค๐ข๐ง๐  ๐ƒ๐ข๐ซ๐ž๐œ๐ญ๐จ๐ซ๐ฒ

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.

Image description

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.

Image description

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.

๐†๐ข๐ญ ๐–๐จ๐ซ๐ค๐Ÿ๐ฅ๐จ๐ฐ ๐Ž๐ฏ๐ž๐ซ๐ฏ๐ข๐ž๐ฐ:

Image description

โ€ข ๐–๐จ๐ซ๐ค๐ข๐ง๐  ๐จ๐ง ๐…๐ข๐ฅ๐ž๐ฌ: 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)