DEV Community

Kunu Wako
Kunu Wako

Posted on

Understanding the Git Workflow: Working Directory, Staging, Commit and Push

Git and GitHub can be very confusing concepts, especially for beginners. The best differentiation is that GitHub is the platform where we store the code, while git is the language we use to store and retrieve this code. When dealing with Git and GitHub, we have to understand the different stages that make up the entire process. From our local computer working directory, to staging the changes, to committing, and finally pushing to GitHub.

Working Directory

Working directory means the folder that we are currently in. It is important to know your working directory as the changes occur here. We check the working directory in cmd by using the command pwd.

When making changes to the files in your working directory, git can see and track the changes. You can check this by using git status.

Staging Area

In the staging area, we put up files that are ready to be committed to your GitHub repository. This is done using the git add command. You can use git add . to stage all the files, or use a specific file's name to stage it.

Commit

After staging, committing your changes creates a snapshot of the current state of the project and stores it in the local git repository. We commit using the git commit -m "" command. The commit message in the quotes is supposed to describe the changes made.

Push

The final stage is the push. This stage uploads the local changes to the remote GitHub repository. We do this using the git push command.

Top comments (0)