What is Git and how does it differ from other version control systems like SVN?
Quick Answer
Git is a distributed version control system where every developer has a full copy of the repository history locally. Unlike centralized systems like SVN, Git allows offline commits, faster branching, and eliminates single points of failure.
Detailed Answer
Think of Git like a personal journal that every team member carries, versus SVN which is like a single shared notebook locked in an office. With Git, you can write entries (commits) anywhere, anytime, and later synchronize your journal with everyone else's. With SVN, you must physically go to the office (connect to the server) to make any entry.
Git is a distributed version control system (DVCS) created by Linus Torvalds in 2005 to manage the Linux kernel source code. The key distinction is that every developer's working copy of the code is also a full repository containing the complete history of all changes. This means you can commit, branch, merge, and view history without any network connection. SVN, by contrast, is centralized: there is one authoritative server, and developers only check out working copies without full history.
Under the hood, Git stores data as snapshots rather than deltas. Each commit captures the state of every file at that point in time, using SHA-1 hashes to ensure integrity. When a file hasn't changed, Git simply links to the previous identical file rather than storing a duplicate. This content-addressable storage model makes operations like branching and merging extremely fast because a branch is just a pointer (40-byte reference) to a commit, not a full copy of files. SVN branches, on the other hand, physically copy directory trees on the server.
In production environments, Git's distributed nature provides natural redundancy. If a central Git server goes down, every developer's clone is effectively a backup. Teams at companies like Netflix and Shopify rely on this property for disaster recovery. The typical workflow involves developers pushing to a shared remote (GitHub, GitLab, Bitbucket) but the local repositories can serve as fallback. This also enables workflows like feature branching, pull requests, and code review that are foundational to modern CI/CD pipelines.
One gotcha that trips up newcomers: Git's staging area (the index) has no equivalent in SVN. In SVN, you modify files and commit them directly. In Git, you must explicitly stage changes with git add before committing. This extra step is intentional, allowing you to craft precise commits from a subset of your changes. Another common surprise is that Git tracks content, not files. Renaming a file is detected heuristically, not recorded explicitly, which can occasionally confuse rename tracking across large refactors.