git.pngGit

Git Workflow Levels

In this article, we will learn about the Workflow levels in Git.

Total Views:   1330


In this article, we will learn about the Workflow levels in Git. Git does not track your all computer files instead of it tracks the directory, Subdirectory, and files where the initialization process is done. Git init command is used for the initialization. The parent directory containing all the files and folders of your project which to be tracked by Git is known as the repository. The working directory, staging area, and commit/Local Repository are part of the local environment. These parts of the Git System exist on the local computer.

1. Working Directory: Working directory is the directory location where the content is created, edited, deleted, etc. All news files which are added for tracking by Git must exist here. Once you initialized the repository, any new file added to that repository is untracked. You need to specify with Git add command that you want Git to track this newly added file.

2. Staging Area: The staging area is an area where all files are gone before taking the snapshots.  After making changes in the working directory, you need to add them to the Staging area. To add the files to the Staging area, we need to use the git add command. It is an intermediate area between the Working directory and the Local repository.

3. Commit or Local Repository: After changes moved to the staging area, the next step is to create a Commit. A commit is a snapshot that represents the current state of your code. With git, you can check the status of the commit, files included in the commit, and go back to the certain previous commit if required. A commit contains the Commit Hash, which uniquely identifies the commit, committed by the author, a list of modifications done in that commit, etc. In Git, we need to use the git commit command to commit the changes. A local repository can be created by cloning the repository from the remote repository or initializing the new local environment.

4. Remote Repository: Remote Repository is a separate Git repository used to collect and host content from one or more local repositories. Its purpose is to share and access the content for multiple users. GitHub, GitLab, etc. are some of the popular remote repositories currently used by the developers. Git push command is used in order to push the files from the local repository to the remote repository.

Git commands like git checkout is used for retrieving the content/code from the local repository to the working directory, git clone command for creating a new local repository from the remote repository, git fetch to update the local repository from the remote repository, git pull is used to fetch the content from the remote repository and update the local repository to match that content. Git pull is the combination of git fetch and git merge command. We will see all git command usage in-depth in the next upcoming articles.