Five Differences Between Git and Subversion

Dis­trib­uted vs. Cen­tral­ized #

One thing you’ve prob­a­bly heard about Git is that it is a DVCS: Dis­trib­uted Ver­sion Con­trol Sys­tem. This means that there’s no require­ment of a cen­tral copy of a repos­i­to­ry. Every copy of a Git repos­i­to­ry con­tains the full his­to­ry of the repos­i­to­ry. You could ini­tial­ize and use a Git repos­i­to­ry on your lap­top and nev­er con­nect to the net­work. It will will perfectly.

SVN, on the oth­er hand, requires a cen­tral­ized repos­i­to­ry that acts as the full record of the his­to­ry of the repository.

You can work with Git using a remote cen­tral­ized repos­i­to­ry (see Git Work­flows sec­tion) but every local copy will still be a self-con­tained repos­i­to­ry that can be used with­out a net­work con­nec­tion to the remote repos­i­to­ry. Even if it’s on a server.

Speed #

Git is said to be faster because all essen­tial oper­a­tions in Git are local and don’t require a net­work con­nec­tion. You can merge, branch, diff, com­mit, and log local­ly and have access to the full repos­i­to­ry history.

Revi­sion Num­bers #

Git iden­ti­fies com­mits (ver­sions) using an SHA1 hash based on the con­tents of the com­mit. Because it’s a hash, the ver­sion num­bers are not sequen­tial. SVN uses sequen­tial num­ber­ing and it’s very pre­dictable that if you’re on revi­sion 426 the next revi­sion will be 427. The SVN way is also sim­pler for step­ping back in time or dis­play­ing a range of com­mits in a log output.

Branch­es and Tags #

Branch­es and tags in SVN are copies of the repos­i­to­ry at a giv­en point in time. You cre­ate branch­es and tags by adding new sub­di­rec­to­ries. In Git, branch­es and tags sim­ply point to a com­mit object (using the com­mit object hash) and do not cre­ate file copies. Branch­es and tags in Git are also not avail­able as sub­di­rec­to­ries in Git. They are obscured by the Git sys­tem direc­to­ry (.git).

Check­ing Out a Repos­i­to­ry #

When work­ing with a remote Git repos­i­to­ry, one require­ment is that you check out the entire repos­i­to­ry. SVN has the con­vienence of allow­ing you to check­out a sub­di­rec­to­ry of a repos­i­to­ry so you only have to down­load the files you need. Git how­ev­er, does not allow this. One work-around to this is to cre­ate a series of small­er repos­i­to­ries in Git and con­nect them using Git Submodules.