Visualising Git Workflow
ΒΆThe Git WorkflowΒΆ
Git has a three-stage architecture that gives you precise control over what gets saved in your project history.
The Three StatesΒΆ
Every file in Git exists in one of three states:
1. π Working DirectoryΒΆ
This is your workspace - where you actually edit files.
# Your project folder
my-project/
βββ index.html β Edit this file
βββ style.css β Make changes here
βββ script.js β Work on your code
Working Directory
- Where you make changes to files
- Just a normal folder on your computer
- Changes here are NOT tracked yet
2. π Staging Area (Index)ΒΆ
This is the preparation zone - where you choose which changes to include in your next commit.
# You edited 5 files, but only want to commit 3
$ git add index.html style.css
# Now these 2 files are "staged" and ready to commit
Why Staging?
The staging area lets you craft perfect commits. You can:
- Group related changes together
- Commit features one at a time
- Review changes before committing
- Leave unfinished work unstaged
3. ποΈ Repository (Local Repo)ΒΆ
This is your permanent history - where Git stores all committed snapshots.
$ git commit -m "Add login feature"
# Your staged changes are now permanently saved in Git's history
Repository
- Complete project history
- Stored in the hidden
.gitfolder - Can recover any previous version
- Shareable with others
The Basic Git WorkflowΒΆ
Here's how the typical workflow looks:
Step-by-Step ExampleΒΆ
Status: Changes are in Working Directory β οΈ (not tracked)
Status: Changes are Committed π (saved in history)
Visualizing the WorkflowΒΆ
graph LR
A[Working<br/>Directory] -->|git add| B[Staging<br/>Area]
B -->|git commit| C[Repository]
C -->|git checkout| A
style A fill:#fff4e6,stroke:#ff9800,stroke-width:3px
style B fill:#e8f5e9,stroke:#4caf50,stroke-width:3px
style C fill:#e3f2fd,stroke:#2196f3,stroke-width:3px
