我已经使用Subversion很多年了,在使用SourceSafe之后,我爱上了Subversion。结合TortoiseSVN,我真的无法想象它还能有什么更好的。
然而,越来越多的开发人员声称Subversion存在问题,我们应该转向新的分布式版本控制系统,比如Git。
Git如何改进Subversion?
我已经使用Subversion很多年了,在使用SourceSafe之后,我爱上了Subversion。结合TortoiseSVN,我真的无法想象它还能有什么更好的。
然而,越来越多的开发人员声称Subversion存在问题,我们应该转向新的分布式版本控制系统,比如Git。
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.
其他回答
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的首选方式是命令行。
SubVersion最让我恼火的一点是它把自己的文件夹放在项目的每个目录中,而git只把一个文件夹放在根目录中。这不是什么大事,但这样的小事积少成多。
当然,SubVersion有Tortoise,它(通常)非常好。
Git和DVCS通常都非常适合于独立编写大量代码的开发人员,因为每个人都有自己的分支。但是,如果您需要从其他人那里进行更改,她必须提交给她的本地回购,然后她必须将该更改集推给您,或者您必须从她那里获取更改集。
我自己的推理也让我认为,如果你做集中发布之类的事情,DVCS会让QA和发布管理变得更加困难。必须有人负责从其他人的存储库中进行推送/拉取,解决任何在最初提交时就可以解决的冲突,然后进行构建,然后让所有其他开发人员重新同步他们的回购。
当然,所有这些都可以通过人工流程来解决;DVCS只是破坏了一些由集中式版本控制修复的东西,以便提供一些新的便利。
我非常喜欢能够在Git中管理源代码的本地分支,而不会混淆中央存储库的水。在许多情况下,我将从Subversion服务器签出代码并运行本地Git存储库,只是为了能够做到这一点。初始化Git存储库不会因为到处都是烦人的.svn文件夹而污染文件系统,这一点也很棒。
至于Windows工具的支持,TortoiseGit处理基本的很好,但我仍然喜欢命令行,除非我想查看日志。我真的很喜欢Tortoise{Git|SVN}在读取提交日志时的帮助方式。
“为什么Git比X好”概述了Git相对于其他scm的各种优缺点。
简要:
Git tracks content rather than files Branches are lightweight and merging is easy, and I mean really easy. It's distributed, basically every repository is a branch. It's much easier to develop concurrently and collaboratively than with Subversion, in my opinion. It also makes offline development possible. It doesn't impose any workflow, as seen on the above linked website, there are many workflows possible with Git. A Subversion-style workflow is easily mimicked. Git repositories are much smaller in file size than Subversion repositories. There's only one ".git" directory, as opposed to dozens of ".svn" repositories (note Subversion 1.7 and higher now uses a single directory like Git.) The staging area is awesome, it allows you to see the changes you will commit, commit partial changes and do various other stuff. Stashing is invaluable when you do "chaotic" development, or simply want to fix a bug while you're still working on something else (on a different branch). You can rewrite history, which is great for preparing patch sets and fixing your mistakes (before you publish the commits) … and a lot more.
有一些缺点:
There aren't many good GUIs for it yet. It's new and Subversion has been around for a lot longer, so this is natural as there are a few interfaces in development. Some good ones include TortoiseGit and GitHub for Mac. Partial checkouts/clones of repositories are not possible at the moment (I read that it's in development). However, there is submodule support. Git 1.7+ supports sparse checkouts. It might be harder to learn, even though I did not find this to be the case (about a year ago). Git has recently improved its interface and is quite user friendly.
在最简单的用法中,Subversion和Git是差不多的。两者之间没有太大区别:
svn checkout svn://foo.com/bar bar
cd bar
# edit
svn commit -m "foo"
and
git clone git@github.com:foo/bar.git
cd bar
# edit
git commit -a -m "foo"
git push
Git真正的亮点在于分支和与其他人一起工作。