Syllabus
Git Tutorial Syllabus: Command Mastery from Basics to Advanced¶
Learn Git Through Commands - Practical, Real-World Focused¶
Module 1: Getting Started¶
- Setup & First Commands
- Installing Git
git config --global user.name "Your Name"git config --global user.email "your@email.com"- Essential configuration for associating work with your identity
- Quick Win: Configure Git in 2 minutes
Module 2: Core Commands - The Daily Essentials¶
- Repository Basics
git init- Create a new repositorygit clone [url]- Download existing project- Concept: What is a repository (local vs remote)?
-
Exercise: Clone a real project from GitHub
-
The Fundamental Workflow
git status- Check state of working directorygit add [file]orgit add .- Stage changesgit commit -m "message"- Save snapshot locallygit commit -a -m "message"- Stage and commit tracked filesgit commit --amend- Modify last commit- Concept: Working Directory → Staging Area → Repository
- VS Code: Using Source Control panel
-
Project: Build a portfolio website with meaningful commits
-
Viewing History
git log- View commit historygit log --oneline- Condensed viewgit log --graph --oneline --all- Visual branch historygit show [commit]- View specific commitgit diff- See unstaged changesgit diff --staged- See staged changes- VS Code: Using Timeline and GitLens
Module 3: Branching Commands¶
- Branch Operations
git branch- List branchesgit branch [branch-name]- Create new branchgit checkout [branch-name]- Switch branchesgit checkout -b [branch-name]- Create and switchgit switch [branch-name]- Modern way to switch branchesgit branch -d [branch-name]- Delete branchgit branch -D [branch-name]- Force delete- Concept: Why branches matter (parallel development)
- VS Code: Bottom-left branch switcher
-
Scenario: Feature development workflow
-
Merging Commands
git merge [branch-name]- Integrate changesgit merge --no-ff [branch-name]- Force merge commitgit merge --abort- Cancel merge during conflicts- Concept: Fast-forward vs three-way merge
- Handling Conflicts: Manual resolution
- VS Code: Conflict resolution interface
- Exercise: Create and resolve conflicts intentionally
Module 4: Remote Repository Commands¶
- Understanding Remotes
git remote -v- List remotesgit remote add origin [url]- Add remotegit remote remove [name]- Remove remotegit remote rename [old] [new]- Rename remote- Concept: Origin (your remote repository)
-
Concept: Upstream (original when forked)
-
Syncing Commands - Push, Pull, Fetch
git push [remote] [branch]- Upload commitsgit push -u origin [branch]- Set upstream and pushgit push --force-with-lease- Safe force pushgit pull- Fetch + Merge automaticallygit fetch- Download without merging (safer)git fetch --all- Fetch from all remotes- Concept: Fetch downloads changes safely, Pull fetches and merges
- When to use what: Fetch for safety, Pull for quick updates
-
Project: Push portfolio to GitHub
-
GitHub Workflow Commands
git clone [url]- Download repository- Fork workflow (on GitHub)
- Creating Pull Requests
- VS Code: GitHub Pull Requests extension
Module 5: Undo & Fix Commands (Essential Survival)¶
-
Undoing Changes
git restore [file]- Discard working directory changesgit restore --staged [file]- Unstage filesgit reset HEAD [file]- Unstage (older way)git reset --soft HEAD~1- Undo commit, keep changes stagedgit reset --mixed HEAD~1- Undo commit, unstage changesgit reset --hard HEAD~1- Undo commit, discard changesgit revert [commit]- Create new commit that undoes changes- Concept: Reset vs Revert (when to use which)
- Common Scenarios: "I committed to wrong branch!"
- VS Code: Undo last commit option
-
Stash Commands
git stash- Temporarily save changesgit stash save "message"- Stash with descriptiongit stash list- View all stashesgit stash pop- Apply and remove latest stashgit stash apply- Apply without removinggit stash apply stash@{n}- Apply specific stashgit stash drop- Remove stashgit stash clear- Remove all stashes- Use Case: Switch branches quickly without committing incomplete work
- VS Code: Stash operations in Source Control
Module 6: Advanced Commands (Power User)¶
-
Rebase Commands
git rebase [branch]- Replay commits on new basegit rebase -i HEAD~n- Interactive rebase (edit history)git rebase --continue- Continue after resolving conflictsgit rebase --abort- Cancel rebasegit rebase --skip- Skip problematic commit- Concept: Rebase creates linear history, avoids merge commits
- Golden Rule: Never rebase public/shared commits
- Interactive Rebase: Squash, reorder, edit, or drop commits
- When: Cleaning feature branch before merging
- Exercise: Squash multiple commits into one
-
Cherry-pick Commands
git cherry-pick [commit]- Apply specific commit to current branchgit cherry-pick [commit1] [commit2]- Multiple commitsgit cherry-pick [commit1]..[commit2]- Range of commitsgit cherry-pick --no-commit [commit]- Apply without committinggit cherry-pick --continue- Continue after conflictgit cherry-pick --abort- Cancel operation- Use Case: Apply bug fix from one branch to another without merging everything
- Scenario: Hotfix to multiple versions
-
Reflog Commands (The Safety Net)
git reflog- View history of HEAD movementsgit reflog show [branch]- Reflog for specific branchgit reset --hard HEAD@{n}- Recover to previous stategit checkout HEAD@{n}- View previous stategit branch [name] HEAD@{n}- Create branch from reflog- Concept: Reflog logs every action that modified HEAD - your undo history
- Use Case: Recover accidentally deleted commits or branches
- Exercise: "Accidentally" delete commits, then recover them
Module 7: Inspection & Comparison Commands¶
-
Advanced Inspection
git log --author="name"- Filter by authorgit log --since="2 weeks ago"- Time-based filteringgit log --grep="keyword"- Search commit messagesgit log -p- Show diff in each commitgit log -- [file]- History of specific filegit blame [file]- See who changed each linegit show [commit]:[file]- View file at specific commitgit diff [branch1]..[branch2]- Compare branchesgit diff [commit1] [commit2]- Compare commits- VS Code: GitLens for inline blame and history
-
Finding Issues
git bisect start- Start binary search for bugsgit bisect bad- Mark current as badgit bisect good [commit]- Mark known good commitgit bisect reset- End bisect session- Use Case: Find which commit introduced a bug
Module 8: Cleaning & Maintenance Commands¶
- Cleanup Commands
git clean -n- Preview what will be removedgit clean -f- Remove untracked filesgit clean -fd- Remove untracked files and directoriesgit clean -fx- Include ignored filesgit gc- Garbage collection (optimize repository)git prune- Remove unreachable objects
Module 9: Collaboration & Workflow Commands¶
-
Tags & Releases
git tag- List tagsgit tag [tag-name]- Create lightweight taggit tag -a [tag-name] -m "message"- Annotated taggit tag -d [tag-name]- Delete local taggit push origin [tag-name]- Push tag to remotegit push origin --tags- Push all tags- Concept: Semantic versioning (v1.0.0, v1.1.0, v2.0.0)
-
Workflow Patterns
- GitHub Flow: main + feature branches + PRs
- Git Flow: main + develop + feature/release/hotfix
.gitignorefile essentials- Commit message conventions
- Branch naming strategies
- Case Study: How professional teams work
Module 10: Configuration & Aliases¶
- Productivity Commands
git config --list- View all settingsgit config --global alias.st status- Create aliasesgit config --global alias.co checkoutgit config --global alias.br branchgit config --global alias.lg "log --graph --oneline"- Useful Aliases: Speed up common operations
- Setting default editor
- Setting merge tool
Module 11: Real-World Problem Solving¶
-
Common Problems & Solutions
- "Detached HEAD state" - What and how to fix
- "Can't push - rejected" - Understanding and fixing
- "Merge conflicts" - Resolving strategies
- "Accidentally committed sensitive data" - Removing from history
- "Lost commits" - Using reflog to recover
- "Wrong branch" - Moving commits between branches
- Troubleshooting Guide: Step-by-step solutions
-
Complete Workflow Scenarios
- Solo developer workflow
- Team collaboration (multiple developers)
- Open source contribution (fork → PR)
- Emergency hotfix procedure
- Release management
- Hands-on: Practice all scenarios
Bonus: Quick Reference¶
- Command Cheat Sheet
- Daily commands quick reference
- VS Code keyboard shortcuts
- Git aliases compilation
- Command comparison table
- Downloadable PDF: Printable cheat sheet
What Makes This Syllabus Command-Focused:¶
✅ Top 12 Essential Commands covered comprehensively
✅ Command-First Approach: Every lesson teaches actual commands
✅ Practical Examples: Real scenarios for each command
✅ VS Code Integration: IDE shortcuts alongside terminal commands
✅ Progressive Complexity: Basic → Intermediate → Advanced
✅ Problem-Solving Focus: Common issues and their command solutions
✅ Hands-On: Every module has practical exercises
Total: 23 lessons, ~70+ commands mastered, 10-12 hours of focused learning
The MkDocs YAML:
- Git:
- 1. Getting Started:
- Setup & First Commands: 'DevOps/Git/1_Setup_First_Commands.md'
- 2. Core Commands - Daily Essentials:
- Repository Basics (init, clone): 'DevOps/Git/2_Repository_Basics.md'
- The Fundamental Workflow (status, add, commit): 'DevOps/Git/2.1_Fundamental_Workflow.md'
- Viewing History (log, show, diff): 'DevOps/Git/2.2_Viewing_History.md'
- 3. Branching Commands:
- Branch Operations (branch, checkout, switch): 'DevOps/Git/3_Branch_Operations.md'
- Merging Commands (merge, conflicts): 'DevOps/Git/3.1_Merging_Commands.md'
- 4. Remote Repository Commands:
- Understanding Remotes (remote commands): 'DevOps/Git/4_Understanding_Remotes.md'
- Push, Pull, Fetch - Syncing Commands: 'DevOps/Git/4.1_Push_Pull_Fetch.md'
- GitHub Workflow Commands: 'DevOps/Git/4.2_GitHub_Workflow.md'
- 5. Undo & Fix Commands:
- Undoing Changes (restore, reset, revert): 'DevOps/Git/5_Undoing_Changes.md'
- Stash Commands: 'DevOps/Git/5.1_Stash_Commands.md'
- 6. Advanced Commands:
- Rebase Commands: 'DevOps/Git/6_Rebase_Commands.md'
- Cherry-pick Commands: 'DevOps/Git/6.1_Cherry_Pick_Commands.md'
- Reflog Commands - The Safety Net: 'DevOps/Git/6.2_Reflog_Commands.md'
- 7. Inspection & Comparison:
- Advanced Inspection Commands: 'DevOps/Git/7_Advanced_Inspection.md'
- Finding Issues (bisect): 'DevOps/Git/7.1_Finding_Issues.md'
- 8. Cleaning & Maintenance:
- Cleanup Commands (clean, gc, prune): 'DevOps/Git/8_Cleanup_Commands.md'
- 9. Collaboration & Workflow:
- Tags & Releases Commands: 'DevOps/Git/9_Tags_Releases.md'
- Workflow Patterns & Best Practices: 'DevOps/Git/9.1_Workflow_Patterns.md'
- 10. Configuration & Productivity:
- Configuration & Aliases: 'DevOps/Git/10_Config_Aliases.md'
- 11. Real-World Problem Solving:
- Common Problems & Command Solutions: 'DevOps/Git/11_Common_Problems.md'
- Complete Workflow Scenarios: 'DevOps/Git/11.1_Workflow_Scenarios.md'
- 12. Quick Reference:
- Command Cheat Sheet: 'DevOps/Git/12_Command_Cheat_Sheet.md'