I’m now having a couple of years experience in using our SVN-client SmartSVN, but I would not call me an “SVN expert”. Since approximately a half year we are using Git to develop our Git-client SmartGit, but I’m definitely neither a Git expert nor an experienced Git user. To be honest, I’m only using the Git features which are available in SmartGit, because I can’t remember all the command line options. Nevertheless, I think I have a good overview over both tools, especially, because I use both for my daily work.
A couple of the following differences might not be just differences between SVN and Git, but differences between classical VCS and distributed VCS (DVCS) in general. Here are some sketched differences in random order which came to my mind when I was asked by a SmartSVN customer:
Git can be used off-line
With SVN you have pristine copies of the files available in the admin-areas which allow, e.g., to see the local uncommitted changes without connection to the SVN server. But if you have to commit your changes, you will need the network connection to the SVN server. With Git you can commit your changes as you like, because you have your own copy of the repository locally available. Only if you want to synchronize your repository with an external one, you need the network connection.
Git has incredible Log performance
Because Git has its own repository locally available, showing a log is a very fast operation. It is not necessary to transfer all the information over network. (We have put quite a lot of effort into SmartSVN’s Log Cache to obtain similar performance.)
Git versions files, SVN also directories
Git, just like CVS, versions only files. You can’t store an empty directory in the repository like with SVN.
Admin files
Git has just one location for its admin files, the .git directory in the root of your working tree. SVN currently scatters its .svn directories over the whole working copy. This makes restructuring (moving or copying) files or directories with Git a no-brainer — with SVN you always have to take care to not move or copy the .svn files to not screw up your working copy. A side-effect is, that reading a Git working tree is much faster than reading a comparably large SVN working copy.
Properties
SVN supports file or directory properties, Git doesn’t. These SVN properties allow, for example, to
- store patterns for files to be ignored (you can define what files/directories should be ignored, but only using .gitignore files similar to the .cvsignore files in CVS)
- define the file type for certain files
- define the line separators which should be used for files
- define URL patterns for the issue tracker, so an SVN-client like SmartSVN can detect issue numbers in commit messages and show them as links
Encoding
SVN has a clear definition of the encoding to use for storing file names or commit messages in the repository (UTF-8). This makes it very platform-independent. You can configure Git to use some special encoding, but it does not enforce it. This reduces Gits inherent platform-independence significantly.
Tagging, Branching
SVN does not have a special tag or branch feature, but the ability to create light-weight copies of whole directory structures can be used in combination with a special repository structure to achieve that. Unfortunately, a lot of SVN users don’t follow the standard repository structure suggested by the SVN team and reinvent their own. This makes it hard for tools like SmartSVN to “transparently” support tags and branches. Git supports tagging and branching as a native feature. In combination with the locally available repository, this has the outstanding advantage that you can create as many local branches you like, e.g. to implement larger features, without the need to store such “shelves” in the central repository.
Multi-Project Repositories
With SVN usually a couple of projects are stored in the same repository, separated only by a certain repository structure. Users can easily check out only certain parts of a larger repository. With Git you have one repository for one project. Everyone working on the project needs to have the complete repository.
Revisions
With SVN it is very easy to refer to a repository state by a revision (a plain number). Git instead uses hash-codes which are hard to read and impossible to remember for humans.
Locking
When working frequently with binary files, SVN’s locking feature is a convenient way to exclusively reserve a certain file for editing for a while. Due to its distributed nature this is not possible with Git.