Introduction
Git is a version control system.
It runs on your computer and keeps track of changes made to your project.
Git workflow are steps you take to move a change from your local files into a shared project history. In its simplest form, it's a pipeline with four stages:
Working Directory → Staging Area → Commit → Push
working directory
Is "Where You Make Changes", It is simply the folder on your computer where your project files are located. You can open and edit a file. Git notices, but it doesn't do anything about it yet. It just marks the file as modified. The current state of the project can be checked using;
git status
Running this command shows you what's changed since your last commit.
Staging area
The staging area is where Git's workflow becomes useful. Instead of committing everything you've changed, you get to pick and choose exactly what goes into your next commit.
git add filename.js
git add .
Commit
A commit takes everything in the staging area and permanently records it in your project's history.
git commit -m"..."
git commit- saves whatever is currently staged.
-m"..." - Explains the contents.
Push
Everything so far has happened locally. Push is the step where your commits travel from your machine to a remote repository like GitHub so others can access them.
git push origin main
Git workflow
# 1. Check what changed
git status
# 2. Stage the changes you want to commit
git add app.js
# 3. Commit with a descriptive message
git commit -m "..."
# 4. Push to the remote repository
git push origin main
Conclusion
Git's workflow — working directory → stage → commit → push — is really just a series of checkpoints that give you control over how your code gets saved and shared.
You edit your files (working directory), pick which changes you want to save (staging), save them for good (commit), and then send them to others (push).
Each step has a purpose: staging lets you choose what to save instead of saving everything at once, committing keeps a safe copy of your work on your own computer, and pushing is when you decide to share that work with others.
Top comments (0)