Skip to main content

Command Palette

Search for a command to run...

Lesson 2 — Git & GitHub Journey

Updated
•2 min read•View as Markdown
Lesson 2 — Git & GitHub Journey
H
Network Engineer with 3+ years of experience in infrastructure, system administration, and enterprise networking, currently transitioning into DevOps and Cloud Engineering. Hands-on experience with Fortinet firewalls, routers, switches, Windows/Linux servers, and Hyper-V virtualization. Currently building and learning with Docker, Kubernetes, AWS, Linux, CI/CD, GitHub Actions, and automation tools while leveraging MERN stack knowledge to understand the complete application lifecycle from development to deployment. Passionate about cloud infrastructure, automation, containers, and modern DevOps practices. Regularly sharing my learning journey, projects, and hands-on experiments.

Understanding File Changes in Git

Today you’ll learn:

  • git diff

  • staging vs unstaging

  • restoring files

  • .gitignore

These are daily-use Git skills.

1. Modify Existing File

Change your file:

touch notes.txt
echo "New line added" >> notes.txt

Now check:

git status

You’ll see:

modified: notes.txt

Git detected changes.

2. View Exact Changes

Use:

git diff

This shows:

  • old content

  • new content

Example:

+ New line added

Meaning:

+ added line
- removed line

Important

git diff shows:

Working Directory vs Staging Area

3. Stage Changes

git add notes.txt

Now:

git status

4. Difference After Staging

You may see nothing.

Why?

Because changes are already staged.

Now use:

git diff --staged

This shows:

Staging Area vs Last Commit

VERY important: Core Git Understanding

git diff
    ↓
unstaged changes

git diff --staged
    ↓
staged changes

5. Unstage File

Suppose you accidentally staged something. Use:

git restore --staged notes.txt

Now file becomes unstaged again.

Check:

git status

6. Restore File (Discard Changes)

Suppose you made bad edits.

Use: git restore notes.txt

This removes uncommitted changes.

git restore <file>
# This removes uncommitted changes.

⚠ Dangerous: Changes are lost permanently.

Real Meaning: git restore file

Means: "Bring file back from last commit"

7. Create Unwanted Files

Example:

touch debug.log
touch secret.env

These should NOT go to Git.

8. Use .gitignore

Create:

touch .gitignore

Add:

*.log
*.env
node_modules/
dist/

Now Git ignores them.

Check: git status

Ignored files disappear.

Why .gitignore Matters

Never upload:

  • secrets

  • passwords

  • API keys

  • cache files

  • build folders

Very important in real projects.

Common .gitignore Examples

Node.js

node_modules/
.env
dist/

Python

__pycache__/
venv/
.env

More from this blog

G

Git, GitHub & Workflows Guide – From Basics to Real DevOps Practices

3 posts

Welcome to my learning journey in Git, GitHub, and modern development workflows. This blog documents my hands-on experience, notes, practical examples, and lessons learned while exploring version control, collaboration, branching strategies, pull requests, automation, CI/CD, and DevOps practices. The goal is to build a structured knowledge base that helps both me and other developers learn through real-world examples and continuous practice.