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)