Five Differences Between Git and Subversion
Distributed vs. Centralized #
One thing you’ve probably heard about Git is that it is a DVCS: Distributed Version Control System. This means that there’s no requirement of a central copy of a repository. Every copy of a Git repository contains the full history of the repository. You could initialize and use a Git repository on your laptop and never connect to the network. It will will perfectly.
SVN, on the other hand, requires a centralized repository that acts as the full record of the history of the repository.
You can work with Git using a remote centralized repository (see Git Workflows section) but every local copy will still be a self-contained repository that can be used without a network connection to the remote repository. Even if it’s on a server.
Git is said to be faster because all essential operations in Git are local and don’t require a network connection. You can merge, branch, diff, commit, and log locally and have access to the full repository history.
Revision Numbers #
Git identifies commits (versions) using an SHA‑1 hash based on the contents of the commit. Because it’s a hash, the version numbers are not sequential. SVN uses sequential numbering and it’s very predictable that if you’re on revision 426 the next revision will be 427. The SVN way is also simpler for stepping back in time or displaying a range of commits in a log output.
Branches and Tags #
Branches and tags in SVN are copies of the repository at a given point in time. You create branches and tags by adding new subdirectories. In Git, branches and tags simply point to a commit object (using the commit object hash) and do not create file copies. Branches and tags in Git are also not available as subdirectories in Git. They are obscured by the Git system directory (
Checking Out a Repository #
When working with a remote Git repository, one requirement is that you check out the entire repository. SVN has the convienence of allowing you to checkout a subdirectory of a repository so you only have to download the files you need. Git however, does not allow this. One work-around to this is to create a series of smaller repositories in Git and connect them using Git Submodules.