Part 2: Commitment Issues? Not Anymore – Git Add, Commit, and Log Basics


Welcome back, folks . In Part 1, we tiptoed into the world of version control, initiated our first Git repo, and made our first commit like proud digital archaeologists. Now, let’s dig deeper into Git’s core moves: adding files, committing like you mean it, and peeking into the past.
The Git Workflow: The Three Stages of File Drama
Here’s the basic Git flow. Every file you touch goes through this cycle:
Modified: You changed the file, and Git noticed. It's side-eyeing you.
Staged: You told Git, “Yes, I want this change tracked.”
Committed: Git says, “Cool. I’ve logged this forever.”
Think of it like:
A chef (you) is preparing ingredients (code) → You put them on the tray (
git add
) → You cook and serve them (git commit
) → Voilà! Dinner is served and versioned.
git add
: Git, Please Notice Me
When you make a change to a file, Git doesn’t track it automatically. You have to explicitly stage it using:
git add filename.txt
Or if you're feeling wild and want to add everything:
git add .
Pro Tip: git add .
adds everything in your directory, including accidental debug files or your 5 MB anime wallpaper. Use it wisely.
git commit
: Save It Like You Mean It
Once staged, lock those changes in with a commit:
git commit -m "Meaningful message about what you did"
Your commit message should explain the why, not just the what.
Bad:
git commit -m "fixed stuff"
Good:
git commit -m "Fix login bug causing crash on invalid email"
Git is your diary. Be honest. Be clear. Be kind to future you.
git status
: What’s Going On?
At any point, you can check what’s happening in your repo with:
git status
This command is like Git whispering in your ear: “Hey, this file is new. That one’s modified. You forgot to commit this one.”
git log
: The Time Machine
Want to revisit history? Use:
git log
And you’ll see something like this:
commit 54a1e6d2d7ab11f...
Author: You <you@example.com>
Date: Today
Add readme.txt with a warm greeting
It’s like scrolling through your past, but without the existential dread. You can even add --oneline
for a cleaner view:
git log --oneline
Bonus: Undoing Oopsies (Safely)
Undo a staged file:
git reset filename.txt
Unmodify a file (revert to last commit):
git checkout -- filename.txt
Git’s like an overprotective parent: it remembers everything. But it lets you fix your mistakes without drama.
TL;DR Table – Git Basics Recap
Command | Description |
git add <file> | Stage changes |
git add . | Stage all current changes |
git commit -m "message" | Commit staged changes |
git status | Show the status of working directory |
git log | Show commit history |
git log --oneline | Shorter version of commit history |
git reset <file> | Unstage a file |
git checkout -- <file> | Revert changes in a file |
So yeah this is it for today . Hope you liked it . Hope you are enjoying the series. and if you haven’t already checked the first blog of the series go and check that out.
Subscribe to my newsletter
Read articles from Shivay Dwivedi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
