Skip to main content

Command Palette

Search for a command to run...

Day 2: The Core Git Workflow: Your "Command Center"

Published
3 min read
Day 2: The Core Git Workflow: Your "Command Center"
S

AI ML Enthusiast Passionate About Learning & Leading

Unlock Your Coding Potential: A 5-Day Journey into Git & GitHub - Day 2: Your Git Command Center

Introduction: On Day 1, we learned how to create a repository and make our first "save" (a commit). But what happens between our changes and that save? And how do we look back at all the saves we've made?

Welcome to Day 2!

Today, we're diving into the essential daily workflow of a Git user. We'll learn how to check the "pulse" of our project, understand the all-important Staging Area, and learn how to look back in time. Think of these tools as your project's command center.

1. git status: Your Best Friend This is the single most important command you will use. Run it often. Run it before you add, before you commit, after you commit... just run it!

git status tells you the exact state of your repository. It answers three key questions:

  • Untracked files: These are new files in your directory that Git doesn't know about yet.

  • Modified files (not staged): These are files Git does know about, but you've changed them and haven't prepared them to be saved.

  • Staged files (to be committed): These are the changes you have prepared and will be included in your next save.

Bash

# Make a change to your file from yesterday
echo "Hello Git... again!" >> hello.txt

# Create a new file
echo "This is a new file" > new_file.txt

# Now, run the command:
git status

You'll see hello.txt listed as "modified" and new_file.txt as "untracked."

2. The Staging Area: The "Why" Behind git add This is the most crucial concept to understand for clean project management.

Problem: Why do we have to git add before we git commit? Why isn't it just one "save" command?

Analogy: Think of your project as a store. Your Working Directory is the entire store where you're walking around, picking things up, and making changes. The Staging Area is your shopping cart. You don't just "save" the whole store at once. You use git add to place specific, related changes into your cart. Your Commit is the act of going through the checkout.

Why is this useful? Imagine you fixed a bug in login.js but also started adding a new feature in profile.js. These are two different tasks. You shouldn't save them in the same commit!

The staging area lets you do this:

  1. Stage only the bug fix: git add login.js

  2. Commit the bug fix: git commit -m "Fix: Corrected login validation bug"

  3. Stage the new feature: git add profile.js

  4. Commit the new feature: git commit -m "Feat: Add user profile section"

This workflow creates a clean, logical, and professional project history that is easy for you (and your teammates) to read later.

3. git log: Your Project's Time Machine You've made commits, but how do you see them? git log is your project's diary.

Running this command shows you a list of all your commits, from newest to oldest. Each entry includes:

  • A commit hash: A unique 40-character ID for that snapshot (e.g., a1b2c3d4...).

  • The Author: Who made the change.

  • The Date: When the change was made.

  • The Commit Message: The message you wrote explaining why you made the change.

Pro-Tip: The default git log can be very detailed. Try this for a cleaner, one-line summary:

Bash

git log --oneline

You'll get a simple list, making it easy to see your project's history at a glance!

Conclusion: Today, you've leveled up from just using Git to understanding it. You now know how to check your project's pulse (git status), craft perfect, intentional commits using the staging area (git add), and look back at your project's history (git log).

Tomorrow, we get to the real "superpower" of Git: Branching! This is where you'll learn how to work on new features safely without breaking your main project.

#GitSeries #VersionControl #GitWorkflow #DeveloperLife #CodingTips #Git