Git Tutorial
- Curriculum Overview
- 1. Introduction to Git & VCS
- 2. Installation & Configuration
- 3. Git Architecture & Concepts
- 4. Basic Workflow (add/commit)
- 5. Git Log & History
- 6. Branching Basics
- 7. Merging & Conflict Resolution
- 8. Git Rebasing
- 9. Undoing Changes
- 10. Working with Remotes
- 11. Git Stashing
- 12. Git Tagging
- 13. Git Ignore & Attributes
- 14. Advanced Git Tools
- 15. Best Practices & Workflows
Git Version Control: The Authoritative Architecture & Engineering Guide
Git is the industry-standard Distributed Version Control System (DVCS) that powers modern collaborative software engineering. Engineered by Linus Torvalds in 2005 for the Linux kernel, Git treats code history not as an arbitrary sequence of file diffs, but as an immutable Directed Acyclic Graph (DAG) of content-addressed snapshots. This comprehensive curriculum demystifies Git from the ground up: the internal mechanics of the .git object store, three-tree index tracking, branch pointer mechanics, linear rebase workflows, and bulletproof disaster recovery via git reflog.
Understand how Git stores files as immutable blobs, directories as trees, and history as cryptographically linked commits indexed by SHA hashes in .git/objects.
Master the flow between the Working Directory (filesystem files), the Staging Area (index binary cache), and the Commit History (HEAD repository snapshot).
Never lose code again. Learn how to recover deleted branches and discarded commits using git reflog, soft/mixed resets, and non-destructive revert commits.
1. The Internal Git Object Database: Blobs, Trees, Commits & Tags
At its core, Git is a content-addressable key-value datastore. When you stage and commit files, Git computes the SHA-1 (or SHA-256) checksum of the object content plus a header, creating a 40-character hexadecimal key, and stores the compressed data under .git/objects/:
Blob (Binary Large Object)
Stores raw file contents in compressed zlib format. Does not store file names, timestamps, or folder paths.
Tree (Directory)
Stores filenames, file permissions (executable vs regular), and pointers to blob SHA hashes or child sub-trees.
Commit
Points to a top-level Tree snapshot, references parent commit SHAs, and stores author/committer metadata with timestamp.
Annotated Tag
An immutable reference pointing to a commit, containing tagger name, date, and optional GPG cryptographic signature.
2. Architectural Comparison: Centralized VCS (SVN) vs. Distributed VCS (Git)
Understanding why modern software engineering migrated away from centralized architectures like Subversion (SVN) to distributed architectures illustrates Git's immense durability and offline speed:
| Architectural Feature | Centralized VCS (SVN, CVS, Perforce) | Distributed VCS (Git, Mercurial) |
|---|---|---|
| Repository Location | Single central server; developers only hold shallow working copies | Every developer clone is a complete mirror of project history |
| Offline Operations | Unable to commit, branch, or view history without network connection | 100% of operations (commit, branch, diff, log, merge) occur locally offline |
| Single Point of Failure (SPOF) | Server corruption or disk crash risks total project history loss | Zero SPOF; any developer clone can restore the entire upstream server |
| Branching Performance | Heavyweight; copies physical directories on the server | Instantaneous; branches are lightweight 41-byte pointer files |
| Merging Model | Prone to merge conflicts due to rigid trunk locking | Three-way recursive merge algorithms and flexible feature branches |
3. Production Blueprint: Interactive Rebasing & History Cleanup
Before submitting a Pull Request for team review, professional developers clean up cluttered commit history (e.g., removing "wip", "fix typo", "lint error" commits) using interactive rebase:
# 1. Start an interactive rebase against the last 4 commits on your feature branch git rebase -i HEAD~4 # In the Git interactive editor, you will see your commits listed in order: # pick a1b2c3d feat(auth): add JWT token parser # pick e4f5g6h wip: add unit test # pick j7k8l9m fix: fix typo in user payload # pick n0p1q2r chore: run linter # 2. Modify commands to squash micro-commits into the main feature commit: # pick a1b2c3d feat(auth): add JWT token parser # squash e4f5g6h wip: add unit test # fixup j7k8l9m fix: fix typo in user payload # fixup n0p1q2r chore: run linter # Note: # 'squash' (s) combines the commit into previous and prompts to edit the combined message. # 'fixup' (f) combines the commit into previous and discards its commit message. # 3. If a conflict occurs during rebase: # Resolve file conflicts manually, stage the resolved files: git add src/auth/jwt.js # Continue the rebase: git rebase --continue # If something goes wrong and you want to abort safely: git rebase --abort
4. Complete Curriculum Directory (15 Comprehensive Modules)
A structured roadmap covering basic workflows, branching strategies, remote collaboration, and enterprise Git tools.
Phase 1: Foundations & Core Architecture (Chapters 1–5)
Phase 2: Branching, Merging & History Rewriting (Chapters 6–9)
Phase 3: Remotes, Automation & Enterprise Tooling (Chapters 10–15)
Frequently Asked Questions: Advanced Git Engineering
Explore Related Tools
Hand-picked utilities and calculators related to this tool.
