我已经使用Subversion很多年了,在使用SourceSafe之后,我爱上了Subversion。结合TortoiseSVN,我真的无法想象它还能有什么更好的。
然而,越来越多的开发人员声称Subversion存在问题,我们应该转向新的分布式版本控制系统,比如Git。
Git如何改进Subversion?
我已经使用Subversion很多年了,在使用SourceSafe之后,我爱上了Subversion。结合TortoiseSVN,我真的无法想象它还能有什么更好的。
然而,越来越多的开发人员声称Subversion存在问题,我们应该转向新的分布式版本控制系统,比如Git。
Git如何改进Subversion?
当前回答
Git还使分支和合并变得非常容易。Subversion 1.5刚刚添加了合并跟踪,但是Git仍然更好。使用Git进行分支是非常快速和廉价的。它使得为每个新特性创建分支更加可行。哦,与Subversion相比,Git存储库的存储空间非常有效。
其他回答
David Richards关于Subversion / GIT的WANdisco博客
The emergence of GIT has brought with it a breed of DVCS fundamentalists – the ‘Gitterons’ – that think anything other than GIT is crap. The Gitterons seem to think software engineering happens on their own island and often forget that most organizations don’t employ senior software engineers exclusively. That’s ok but it’s not how the rest of the market thinks, and I am happy to prove it: GIT, at the last look had less than three per cent of the market while Subversion has in the region of five million users and about half of the overall market. The problem we saw was that the Gitterons were firing (cheap) shots at Subversion. Tweets like “Subversion is so [slow/crappy/restrictive/doesn't smell good/looks at me in a funny way] and now I have GIT and [everything works in my life/my wife got pregnant/I got a girlfriend after 30 years of trying/I won six times running on the blackjack table]. You get the picture.
其他的回答很好地解释了Git的核心特性(这些特性非常棒)。但是还有很多小方法可以让Git表现得更好,并帮助我的生活更加理智。以下是一些小细节:
Git has a 'clean' command. SVN desperately needs this command, considering how frequently it will dump extra files on your disk. Git has the 'bisect' command. It's nice. SVN creates .svn directories in every single folder (Git only creates one .git directory). Every script you write, and every grep you do, will need to be written to ignore these .svn directories. You also need an entire command ("svn export") just to get a sane copy of your files. In SVN, each file & folder can come from a different revision or branch. At first, it sounds nice to have this freedom. But what this actually means is that there is a million different ways for your local checkout to be completely screwed up. (for example, if "svn switch" fails halfway through, or if you enter a command wrong). And the worst part is: if you ever get into a situation where some of your files are coming from one place, and some of them from another, the "svn status" will tell you that everything is normal. You'll need to do "svn info" on each file/directory to discover how weird things are. If "git status" tells you that things are normal, then you can trust that things really are normal. You have to tell SVN whenever you move or delete something. Git will just figure it out. Ignore semantics are easier in Git. If you ignore a pattern (such as *.pyc), it will be ignored for all subdirectories. (But if you really want to ignore something for just one directory, you can). With SVN, it seems that there is no easy way to ignore a pattern across all subdirectories. Another item involving ignore files. Git makes it possible to have "private" ignore settings (using the file .git/info/exclude), which won't affect anyone else.
Git并不比Subversion好。但也不是更糟。这是不一样的。
关键的区别在于它是去中心化的。想象一下你是一个在路上的开发人员,你在你的笔记本电脑上开发,你想要有源代码控制,这样你就可以回到3小时前。
使用Subversion时,您会遇到一个问题:SVN存储库可能位于您无法到达的位置(在您的公司中,并且您目前没有互联网),您无法提交。如果你想复制你的代码,你必须复制/粘贴它。
使用Git,您就不会遇到这个问题。您的本地副本是一个存储库,您可以提交它并获得源代码控制的所有好处。当您重新获得到主存储库的连接时,您可以针对它提交。
一开始看起来不错,但是要记住这种方法增加了复杂性。
Git似乎是“新的、闪亮的、酷的”东西。它绝对不坏(毕竟Linus为Linux内核开发写了它是有原因的),但是我觉得很多人只是因为它是新的并且是由Linus Torvalds写的,就跳上了“分布式源代码控制”这列火车,而不知道为什么/它是否更好。
Subversion有问题,但是Git、Mercurial、CVS、TFS等等也有问题。
编辑:所以这个答案现在已经有一年了,仍然获得了很多赞,所以我想我会添加更多的解释。在写这篇文章后的去年,Git获得了很多动力和支持,特别是在像GitHub这样的网站真正起飞之后。我现在同时使用Git和Subversion,我想分享一些个人见解。
First of all, Git can be really confusing at first when working decentralized. What is a remote? and How to properly set up the initial repository? are two questions that come up at the beginning, especially compared to SVN's simple "svnadmin create", Git's "git init" can take the parameters --bare and --shared which seems to be the "proper" way to set up a centralized repository. There are reasons for this, but it adds complexity. The documentation of the "checkout" command is very confusing to people changing over - the "proper" way seems to be "git clone", while "git checkout" seems to switch branches.
当你去中心化的时候,Git真的会发光。我家里有一台服务器,路上有一台笔记本电脑,SVN在这里根本不能很好地工作。使用SVN,如果我没有连接到存储库,我就不能进行本地源代码控制(是的,我知道SVK或复制回购的方法)。对于Git,这是默认模式。这是一个额外的命令(git commit在本地提交,而git push origin master将主分支推到名为“origin”的远程)。
如上所述:Git增加了复杂性。创建存储库的两种模式,签出vs克隆,提交vs推…您必须知道哪些命令在本地工作,哪些命令在“服务器”上工作(我假设大多数人仍然喜欢中央的“主存储库”)。
而且,工具仍然不够,至少在Windows上是这样。是的,有一个Visual Studio插件,但我仍然使用git bash和msysgit。
SVN的优点是学习起来简单得多:有您的存储库,所有针对它的更改,如果您知道如何创建、提交和签出,您就可以准备好,并可以在以后提取分支、更新等内容。
Git的优势在于,如果一些开发人员不总是连接到主存储库,它会更适合。而且,它比SVN快得多。据我所知,分支和合并支持要好得多(这是意料之中的,因为这是编写它的核心原因)。
这也解释了为什么它在互联网上获得了如此多的关注,因为Git非常适合开源项目:只需Fork它,将您的更改提交到您自己的Fork,然后让原始项目维护者提取您的更改。使用Git,这就可以了。真的,在Github上试试吧,太神奇了。
我还看到了Git-SVN网桥:中央存储库是一个Subversion repo,但开发人员在本地使用Git,网桥将他们的更改推到SVN。
但是即使有了这么长的补充,我仍然坚持我的核心信息:Git并没有更好或更差,它只是不同而已。如果你需要“离线源代码控制”,并愿意花一些额外的时间学习它,那就太棒了。但是如果您有一个严格集中的源代码控制,并且/或者因为您的同事不感兴趣而在第一时间努力引入源代码控制,那么SVN的简单性和出色的工具(至少在Windows上)就会脱颖而出。
我非常喜欢能够在Git中管理源代码的本地分支,而不会混淆中央存储库的水。在许多情况下,我将从Subversion服务器签出代码并运行本地Git存储库,只是为了能够做到这一点。初始化Git存储库不会因为到处都是烦人的.svn文件夹而污染文件系统,这一点也很棒。
至于Windows工具的支持,TortoiseGit处理基本的很好,但我仍然喜欢命令行,除非我想查看日志。我真的很喜欢Tortoise{Git|SVN}在读取提交日志时的帮助方式。
为什么我认为Subversion比Git好(至少对于我所从事的项目来说),主要是因为它的可用性和更简单的工作流程:
http://www.databasesandlife.com/why-subversion-is-better-than-git/