git

Git and GitHub have become essential for developers, data scientists, DevOps engineers, and even technical writers. Whether you’re solo or on a global team, mastering version control boosts collaboration, reduces errors, and builds confidence.

This guide gives you a complete roadmap—from core concepts to professional workflows—with simple setup steps for Windows, Linux, and macOS, plus clean, real-world command practices.

🗺️ Roadmap to Learning Git & GitHub

1️⃣ Understand the Core Concepts
Before using commands, know what Git actually does:

  • Git is a distributed version control system
  • GitHub hosts Git repositories online
  • Git tracks changes, not files
  • Every change is stored as a commit
  • Branches enable parallel development

Key terms: Repository, Commit, Branch, Merge, Remote, Pull request

2️⃣ Local Git vs Remote GitHub

  • Local (Git): Runs on your machine, tracks changes offline, uses commits
  • Remote (GitHub): Hosted online, stores shared code, enables collaboration

Learn Git first—then GitHub.

⚙️ Git Setup Guide (All Platforms)

🪟 Windows

  • Download from https://git-scm.com/downloads
  • Install with defaults (choose Git Bash, VS Code as editor, and “Checkout Windows-style, commit Unix-style”)
  • Verify: git –version

🐧 Linux

  • Ubuntu/Debian: sudo apt update && sudo apt install git -y
  • Fedora: sudo dnf install git
  • Verify: git –version

🍎 macOS

  • With Homebrew: brew install git
  • Or: xcode-select –install
  • Verify: git –version

🔧 Initial Git Configuration (Do this once!)
git config –global user.name “Your Name”
git config –global user.email “your@email.com
Check: git config –list

📂 Creating and Managing a Repository
Start a new project:
mkdir my-project
cd my-project
git init

Check status: git status
Stage files: git add file.txt or git add .
Commit: git commit -m “Initial project setup”
→ Always write clear, meaningful messages.

🌐 Connecting to GitHub
Link remote: git remote add origin https://github.com/username/repo-name.git
Check: git remote -v
First push:
git branch -M main
git push -u origin main

🔄 Daily Git Workflow
Always pull first: git pull origin main
Review history: git log or git log –oneline

🌿 Working with Branches
Create: git switch -c feature-login
Switch: git switch main
Push branch: git push origin feature-login

🔀 Merging Branches

  1. git switch main
  2. git pull origin main
  3. git merge feature-login
  4. git push origin main

⚠️ Handling Merge Conflicts

  • Edit conflicted files manually
  • Stage fix: git add file.txt
  • Commit: git commit -m “Resolve merge conflict”

🧹 Undoing Mistakes Safely

  • Undo last commit (keep changes): git reset –soft HEAD~1
  • Discard file changes: git checkout — file.txt
  • Remove untracked files: git clean -f

🚀 Professional GitHub Practices

  • Use a branch for every feature
  • Commit small, logical changes
  • Write meaningful messages
  • Always pull before pushing
  • Never commit secrets
  • Use .gitignore

📄 Example .gitignore
.env
node_modules/
vendor/
.DS_Store

🧠 Final Learning Path Summary

  1. Learn Git basics
  2. Practice commits daily
  3. Use branches for every task
  4. Push to GitHub regularly
  5. Master merging & conflict resolution
  6. Follow clean, consistent workflows
  7. Contribute to open source

✅ Conclusion
Git and GitHub are more than tools—they’re professional habits. With practice and discipline, they become your most reliable allies in building real-world projects confidently and cleanly.