Skip to content

sahastraWin/GitLearningWithSJ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 GitLearningWithSJ

Git GitHub Maintained by SJ PRs Welcome

"Git is not memorization. It is understanding the graph."

A comprehensive, hands-on laboratory dedicated to mastering version control, branching strategies, and the underlying architecture of Git. This repository serves as a visual and technical roadmap for professional-grade Git proficiency.


🎬 Git in Action

Git Workflow Animation

The fundamental Git workflow — Working Directory → Staging Area → Repository


🛠️ Commands Mastered

I have moved beyond basic commits to understanding history manipulation and repository maintenance:

Category Commands
Setup & Config git init, git config
Snapshots git add, git commit, .gitignore
Navigation git log, git switch, git branch
History Control git restore, git commit --amend
Integration git merge --no-ff, git rebase

📊 Visualization: The Power of the Graph

Git DAG — Directed Acyclic Graph

A Directed Acyclic Graph (DAG) — the true data structure behind every Git repository

To view the complete evolutionary history of this project, run:

git log --oneline --graph --all --decorate

Sample output:

* a3f9c12 (HEAD -> main) Final release polish
*   d7b2e88 Merge branch 'feature/contact'
|\
| * 9c1f034 (feature/contact) Add contact form
* |   5e4a110 Merge branch 'feature/hero'
|\ \
| * | 3b8d221 (feature/hero) Design hero section
|/ /
* | 1a6c903 (bugfix/typo) Fix typo in README
|/
* 0f2d745 (release/v1.0) Initial stable build

🌿 Branching Strategy

Git Branching Strategy

Long-running and topic branches — the backbone of professional Git workflows

This project follows a professional naming convention (Feature/Bugfix/Release) to simulate a real-world development environment:

  • feature/navbar — Navigation component implementation.
  • feature/hero — Hero section design and logic.
  • feature/contact — Contact form integration.
  • 🐛 bugfix/typo — Correction of documentation and string literals.
  • 🔥 hotfix/crash — Critical patch for runtime stability.
  • 📦 release/v1.0 — Production-ready stable build.

🔁 Merge vs. Rebase

Git Rebase Diagram

Rebase replays your commits on top of the target branch for a clean, linear history

Strategy Command Result
Merge (no-ff) git merge --no-ff feature/x Preserves branch history with a merge commit
Rebase git rebase main Replays commits on top for a clean linear history
Fast-forward git merge feature/x Moves pointer forward if no divergence

💡 Rule of thumb: Use rebase for local cleanup before pushing; use merge --no-ff on shared branches to preserve context.


📁 The Three States of Git

Git Three States — Working Directory, Staging Area, Repository

Every file in Git lives in one of three states — understanding this is the foundation of everything

Working Directory  ──── git add ────▶  Staging Area  ──── git commit ────▶  .git Repository
      │                                                                              │
      │◀──────────────────────── git checkout / git restore ──────────────────────────│

🏷️ Commit History & Parent Pointers

Git Commit History and Parent Pointers

Each commit is a snapshot that points back to its parent — this chain IS your history

Use Conventional Commits for clean, readable logs:

feat:     ✨ New feature
fix:      🐛 Bug fix
docs:     📝 Documentation update
style:    💅 Formatting (no logic change)
refactor: ♻️  Code restructure
test:     🧪 Adding/fixing tests
chore:    🔧 Tooling, config, maintenance

🗂️ .gitignore — Repository Hygiene

# Dependencies
node_modules/
vendor/

# Build outputs
/dist
/build
*.o
*.class

# Environment & secrets
.env
.env.local
*.pem

# OS artifacts
.DS_Store
Thumbs.db

# IDE configs
.vscode/
.idea/
*.suo

💡 Key Learning Objectives

  • Three States: Working Directory, Staging Area, and .git Directory.
  • Fast-forward vs Recursive merges: Knowing when each strategy applies.
  • Rebase for clean history: Linear, readable commit logs for production repos.
  • .gitignore mastery: Maintaining repository hygiene from day one.
  • Branch naming conventions: Professional Feature/Bugfix/Release/Hotfix strategy.
  • History manipulation: git commit --amend, git restore, selective staging.

📚 Quick Reference Cheatsheet

# Start a repo
git init && git remote add origin <url>

# Stage and commit
git add .
git commit -m "feat: add navbar component"

# Branch workflow
git switch -c feature/my-feature
git switch main
git merge --no-ff feature/my-feature

# Clean up history before PR
git rebase main
git commit --amend --no-edit

# Inspect the graph
git log --oneline --graph --all --decorate

Keep Going!

"Every expert was once a beginner. Keep committing."

Maintained with 💙 by Sahastrajeet (SJ)

About

A curated collection of Git and GitHub tutorials, command references, and hands-on exercises designed to master version control from scratch.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors