22

I am currently deep into Git before ever mastering SVN. Its my first serious source control management system learning experience.

I wonder about the opportunity-cost of not learning (or even de-learning what little I learned about) SVN. Is there something that I need to watch out for?

Are there things that are just not doable or prohibitively hard in Git as compared to SVN?

Top-Master
  • 7,611
  • 5
  • 39
  • 71
explorer
  • 11,710
  • 5
  • 32
  • 39
  • Have you seen: http://stackoverflow.com/questions/161541/svn-vs-git ? – Sander Feb 24 '11 at 08:31
  • @Sander ... I have already gone through most of whats being said about this on SO, but couldn't pin down anything that addresses this satisfactorily . The question you linked to is two and a half years old ... that's about two and a half centuries time in this area. Anyways I have gone that thread as well. – explorer Feb 24 '11 at 08:52
  • Sure, but it helps if you show that in your question ;) Then others know you have put some effort in it already and that helps composing a better answer hopefully! – Sander Feb 24 '11 at 09:25
  • In my opinion better to ask vise versa 'What can svn NOT do, that git can do ?' ;) Git can easy switch between branches and it not get stuck when i move, delete, remove folders/files. – Andrew Orsich Mar 23 '11 at 09:13
  • FYI: http://svnvsgit.com/ – bahrep Jan 08 '16 at 12:01

13 Answers13

15

Git can not svn lock documents, so that someone could prevent others from editing a non-auto-mergeable entity (such as Word or Excel file).

P Shved
  • 96,026
  • 17
  • 121
  • 165
  • 1
    Locking for a DVCS like Git would not make much sense unless done on the server side. – Mot Jul 06 '12 at 10:42
  • @MikeL.: Yes, of course. Still, there's no fundamental reason why `git` would not be able to support this functionality. It has simply not been implemented. Of course, locking would only work while you are online... – sleske Oct 04 '12 at 13:16
  • @sleske: Git is intended as a version control system, not as an access control system. Although there is 3rd party software, that does this on top of Git (e.g. gitolite). Besides, mechanisms such as pull/merge requests handle this issue in a much more sensible manner than locking files anyway. – Emilia Bopp Feb 23 '14 at 18:30
  • 1
    @aepsil0n: I think you misunderstand. SVN file locking is not an access control mechanism (it can be overridden) - it's a mechanism to avoid two people editing the same file simultaneously. This can be useful for files that are difficult to merge, e.g. image files. – sleske Feb 23 '14 at 19:12
  • You're right, I indeed misunderstood. Thanks for the clarification. Isn't this roughly equivalent to Git not letting you push conflicting changes by default? I mean, in the end nothing is going to prevent you from editing locally anyway. I find it hard to see how this feature is applicable in a DVCS context. – Emilia Bopp Feb 24 '14 at 11:01
  • 1
    @aepsil0n: Yes, it is roughly similar. The difference is that with SVN locking you lock (or are supposed to lock) a file *before* editing it - so two people cannot edit the same file without knowing. There is no such mechanism in git, you only find out after the fact. – sleske Feb 25 '14 at 08:27
14

Git can't check out a subtree and use that as though it was a complete repository.

For example, with Subversion you can check out the directory "trunk" and use that as if it was a repository. You can also check out "branches/feature1" and use that. With Git it's only possible to check out the root directory (although with recent versions you can do a sparse checkout which doesn't download all files, you still have to check out the root though). In Git you would use branches instead of checking out subtrees.

Theo
  • 131,503
  • 21
  • 160
  • 205
  • 4
    Actually, SVN can't check-out a subtree and use that as a complete *repository* either. SVN working copies, or Git working trees for that matter, aren't *repositories*. In Git you most certainly can check out a subtree: `git checkout `. That command checks out a subtree of the files from the repository, just like SVN can -- you just have to clone the repository first. In SVN, the only reason you don't have to clone the repository first is because SVN isn't a *distributed* VCS... What? Why are you looking at me like that? – Dan Moulding Feb 25 '11 at 15:20
  • 3
    @DanMoulding: True. However, in practice SVN lets you checkout a subtree and commit from it. In Git, you cannot fetch a subtree in a way that would let you commit to it and push your commits upstream. – sleske Aug 31 '12 at 08:25
  • Git has http://programmers.stackexchange.com/questions/111633/what-does-svn-do-better-than-git#comment-336451 – Pacerier Mar 25 '15 at 17:42
13

I think that one of the few use cases where you might prefer to use Subversion instead of git is if you're trying to manage a very large repository of binary media where people mostly only want the most recent version. e.g. say you're developing a game, and the artists need to track revisions of all the artwork, but the entire history of the repository would be huge (100s of gigabytes)

To be fair to git, this is a use case that's very far from what it was designed to do (manage source code repositories) and there are various workarounds or extensions that might help if you really want to use git for that, e.g.:

  • Shallow clones
  • Scott Chacon's git-media extension
  • Joey Hess's similar project, git annex
  • Using Avery Pennarun's bup to create pack files directly

... but it's still an area where one would probably prefer SVN. There's an brief presentation on this subject from a GitTogether a couple of years ago.

Mark Longair
  • 446,582
  • 72
  • 411
  • 327
8

Git can't store empty directories. Arguably, this is an advantage, but it is one thing that git can't do but svn can.

Tyler
  • 21,762
  • 11
  • 61
  • 90
  • 2
    It is not an advantage in all cases, as there are times when directories that contain no source code are important. For example, when you want to track revisioning on directory trees, that are the "source" of your packaging project. – Edwin Buck Aug 22 '13 at 16:00
4

This Wiki has a nice comparison: https://git.wiki.kernel.org/index.php/GitSvnComparison

Summarized

  • Git is much faster than Subversion
  • Subversion allows you to check out just a subtree of a repository; Git requires you to clone the entire repository (including history) and create a working copy that mirrors at least a subset of the items under version control.
  • Git's repositories are much smaller than Subversions (for the Mozilla project, 30x smaller)
  • Git was designed to be fully distributed from the start, allowing each developer to have full local control
  • Git branches are simpler and less resource heavy than Subversion's
  • Git branches carry their entire history
  • Merging in Git does not require you to remember the revision you merged from (this benefit was obviated with the release of Subversion 1.5)
  • Git provides better auditing of branch and merge events
  • Git's repo file formats are simple, so repair is easy and corruption is rare.
  • Backing up Subversion repositories centrally is potentially simpler - since you can choose to distributed folders within a repo in git
  • Git repository clones act as full repository backups
  • Subversion's UI is more mature than Git's
  • Walking through versions is simpler in Subversion because it uses sequential revision numbers (1,2,3,..); Git uses unpredictable SHA-1 hashes. Walking backwards in Git is easy using the "^" syntax, but there is no easy way to walk forward.
Lieven Keersmaekers
  • 57,207
  • 13
  • 112
  • 146
Sander
  • 1,244
  • 1
  • 12
  • 24
  • 6
    explorer did not ask about the advantages of Git over SVN, but about the disadvantages. – Mot Feb 24 '11 at 10:06
  • 1
    The wiki page you refer to has many issues according to http://svnvsgit.com/. You simply copy-pasted wrong info. – bahrep Jan 08 '16 at 12:02
  • Thanks @bahrep for your comment, however it was posted nearly 4 years ago. Can you specify what is inaccurate according to your information? – Sander Jan 08 '16 at 16:01
  • 1
    @Sander **Git's repositories are much smaller than Subversions (for the Mozilla project, 30x smaller)** this one, and this one **Git branches are simpler and less resource heavy than Subversion's** and this one **Git branches carry their entire history** (SVN branches carry whole history as well), and **Git provides better auditing of branch and merge events** and **Git's repo file formats are simple, so repair is easy and corruption is rare.** – bahrep Jan 08 '16 at 16:03
3

Subversion is a central repository

While many people will want to have distributed repositories for the obvious benefits of speed and multiple copies, there are situations where a central repository is more desirable. For example, if you've got some critical piece of code that you don't want anyone to access, you'd probably not want to put it under Git. Many corporations want to keep their code centralized, and (I guess) all (serious) government projects are under central repositories.

Subversion is conventional wisdom

This is to say that many people (especially managers and bosses) have the usual way to number the versions and seeing the development as a "single line" along time hardcoded into their brain. No offense, but Git's liberality is not easy to swallow. The first chapter of any Git book tells you to blank out all the conventional ideals from your mind and start anew.

Subversion does it one way, and nothing else

SVN is a version control system. It has one way to do its job and everybody does it the same way. Period. This makes it easy to transition to/from SVN from/to other centralized VCS. Git is NOT even a pure VCS -- it's a file-system, has many topologies for how to set up repositories in different situations -- and there isn't any standard. That makes it harder to choose one.

Other advantages are:

SVN supports empty directories
SVN has better Windows support
SVN can check out/clone a sub-tree
SVN supports exclusive access control svn lock which is useful for hard-to-merge files
SVN supports binary files and large files more easily (and doesn't require copying old versions everywhere).
Adding a commit involves considerably fewer steps since there isn't any pull/push and your local changes are always implicitly rebased on svn update.

Found this and agree with it. Again the newbees are pretty agro when you touch git. I cannot trust git or github until a few more security changes like going one step beyond the hackable ssh keys.

3
  • Git has no serious (platform-independent) support for non-US-ASCII characters in file names and commit messages, git just stores the byte-representation of the characters it gets from the OS instead of translating it.
  • Git can't record which particular commits have been cherry-picked.
Mot
  • 28,248
  • 23
  • 84
  • 121
  • 4
    git commit messages are always UTF-8 unless you specifically configure your repository to use a legacy encoding, so git fully supports all Unicode characters in commit messages. – CB Bailey Feb 25 '11 at 11:58
  • According to my (quite limited) knowledge of Git, it does NOT do any encoding transformation from platform-specific text encoding to UTF-8, but SVN does definitely. – Mot Feb 25 '11 at 18:46
  • UTF-8 in commit messages should not generally be a problem - you just need an editor that understands UTF-8. UTF-8 in filenames should now also work, at least on Windows. It definitely works using Cygwin+git, and msysgit apparently fixed it in 1.7.10 ( http://stackoverflow.com/questions/829682/what-dvcs-support-unicode-filenames/1274142#1274142 ). – sleske Jul 06 '12 at 08:59
  • However, UTF-8 filenames on MacOS still seem to be a problem, because of the Unicode normalization that HFS+ applies... – sleske Jul 06 '12 at 09:14
3

For us the most important feature of SVN ist the ability to repositoy-wide lock files. Since we work with binyary and unmergeable CAD files the merge-based workflow of any DVCS doesn't work here.

Rudi
  • 19,366
  • 3
  • 55
  • 77
2

You cannot restrict read access to a part of the repo (i.e. only allow reading of certain files, or only part of the history). This is a direct consequence of the fact that you can only clone a complete repository (as explained in Theo's and Mark Longair's answer). If you want different levels of read access for different files, you must put them into different repositories (which can be included as submodules into the main repo).

Note that you can restrict write access to a repo based on many criteria (path, file name, history modification). You need to use special software in addition to git to do this (such as gitosis ), but that is similar with Subversion.

In practice the above is not usually a problem, because in Git the idea is that a repository contains files that are typically used together (such as the source code of one program or project) - so usually restricting read access to a part is pointless, because you need all the files to build/work with the project. However, if you put many loosely related things into one git repo, this may bite you.

sleske
  • 81,358
  • 34
  • 189
  • 227
2

I would say that you can do almost everything that matters in git and even more than subversion enables you to do. That should not be your worry. However both are popular and deserve your attention especially if you are in opensource programming.

I would however consider git to be harder to learn but once you got the hang of it people are usually addicted and find other SCMs inferior. The distributed support for git is excellent (there are others as well, but git is probably the most widespread) which happens to be useful for a bunch of other tasks than managing source code alone. git can be considered a ZIP-utility on steroids and can be quickly deployed to track general filesystem changes and to replicate changes between hosts in an efficient manner.

On windows there are some issues with git:

  • Unicode filename support is buggy in many implementations. This gets better all the time, but still it is a problem.
  • Explorer plugins are not that good on Windows. I find it easier to use the command line version instead.

But I would consider things that git has and SVN does not. Not having excplicit support for branches in SVN is a major issue - the git implementation is very nice and lets you branch without even thinking of branches. Being able to work offline is a major treat as well.

Anders Zommarin
  • 7,094
  • 2
  • 25
  • 24
2
  1. SVN is practical for working with multi-terabyte repos over the Internet.
  • Technically, Git can handle it too, but cloning the whole multi-T repo over the Internet... well - I prefer to start working the same day I got the URL to the repo, not 10 days afterwards.
  • NB: strategy of "splitting the whole thing onto multiple repos" doesn't always work either. If we as a gamedev team have a multi-T game repo (which includes both source code and assets, and both #1 and #2 are necessary for assets) - we certainly need to have our game built from one single repo (otherwise the whole thing becomes irreproducible without multiple repo refs - which is a Bad Thing(tm)).
  1. SVN can lock files, which is often a Good Thing(tm) for non-mergeable binaries (merging JPEG, anyone?)
  2. With SVN, you have a monotonous revision (so revision 357 is always newer than revision 350). While relatively minor, this is Damn Convenient(tm).
  3. SVN can restrict read access with less-than-whole-repository granularity.
  4. A bit of rant on Git: SVN can handle revert of merge without jumping through counter-intuitive hoops to re-introduce some of reverted changes later (see Rollback a Git merge for details).
No-Bugs Hare
  • 1,557
  • 14
  • 15
1

Two more things svn can do and I miss in git:

  1. externals (something like symbolic links in repository namespace)
  2. keyword expansion (automatic file content change during checkout/update)
Othmar Wigger
  • 111
  • 1
  • 4
1

With Git's distributed nature, there is no single place (server) where you/sysadmin can backup the entire code base. Each node must take their own backups or merge daily to a node which takes daily backups.

Mark Bathie
  • 180
  • 1
  • 1
    You can easily set up a git repo to act as a "master" repo, similar to any non-distributed VCS, so that's hardly a problem (you still have the backup problem on the master node, regardless of the VCS). On the other hand, if git nodes are pushing/pulling regularly then you have multiple redundancy built in, and barely even need backups... – naught101 Mar 13 '12 at 13:09