我已经使用Subversion很多年了,在使用SourceSafe之后,我爱上了Subversion。结合TortoiseSVN,我真的无法想象它还能有什么更好的。

然而,越来越多的开发人员声称Subversion存在问题,我们应该转向新的分布式版本控制系统,比如Git。

Git如何改进Subversion?


当前回答

Subversion非常容易使用。在过去的几年里,我从来没有发现任何问题或事情没有像预期的那样工作。此外,还有许多优秀的GUI工具,对SVN集成的支持也很大。

With Git you get a more flexible VCS. You can use it the same way like SVN with a remote repository where you commit all changes. But you can also use it mostly offline and only push the changes from time to time to the remote repository. But Git is more complex and has a steeper learning curve. I found myself in the first time committing to wrong branches, creating branches indirectly or get error messages with not much informations about the mistake and where I must search with Google to get better informations. Some easy things like substitution of markers ($Id$) doesn't work but GIT has a very flexible filtering and hook mechanism to merge own scripts and so you get all things you need and more but it needs more time and reading of the documentation ;)

如果您主要脱机使用本地存储库,那么如果本地机器上丢失了某些东西,则没有备份。使用SVN,您主要使用远程存储库,同时您的备份也在另一个服务器上… Git也可以以同样的方式工作,但这并不是Linus的主要目标,要有类似SVN2的东西。它是为Linux内核开发人员和分布式版本控制系统的需要而设计的。

Git比SVN好吗?只需要一些版本历史记录和备份机制的开发人员可以轻松地使用SVN。经常使用分支、同时测试更多版本或主要离线工作的开发人员可以从Git的特性中受益。有一些非常有用的特性,比如SVN中没有的存储特性,可以使工作更轻松。但另一方面,并非所有人都需要所有功能。所以我看不到SVN的死角。

Git需要一些更好的文档,错误报告必须更有帮助。而且现有的有用的gui也很少。这次我只找到了一个支持大多数Git特性的Linux GUI (Git -cola)。Eclipse集成正在工作,但还没有正式发布,也没有官方更新站点(只有一些外部更新站点,从主干定期构建http://www.jgit.org/updates) 因此,现在使用Git的首选方式是命令行。

其他回答

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上)就会脱颖而出。

谷歌技术讲座:Linus Torvalds谈git

http://www.youtube.com/watch?v=4XpnKHJAok8

Git Wiki的比较页面

http://git.or.cz/gitwiki/GitSvnComparsion

Git还使分支和合并变得非常容易。Subversion 1.5刚刚添加了合并跟踪,但是Git仍然更好。使用Git进行分支是非常快速和廉价的。它使得为每个新特性创建分支更加可行。哦,与Subversion相比,Git存储库的存储空间非常有效。

Subversion仍然是一种更常用的版本控制系统,这意味着它有更好的工具支持。您会发现几乎所有IDE都有成熟的SVN插件,并且有很好的资源管理器扩展可用(如TurtoiseSVN)。除此之外,我不得不同意Michael的观点:Git并不比Subversion更好或更差,它是不同的。

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.