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

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

Git如何改进Subversion?


当前回答

我喜欢DVCS的主要原因是:

You can commit broken things. It doesn't matter because other peoples won't see them until you publish. Publish time is different of commit time. Because of this you can commit more often. You can merge complete functionnality. This functionnality will have its own branch. All commits of this branch will be related to this functionnality. You can do it with a CVCS however with DVCS its the default. You can search your history (find when a function changed ) You can undo a pull if someone screw up the main repository, you don't need to fix the errors. Just clear the merge. When you need a source control in any directory do : git init . and you can commit, undoing changes, etc... It's fast (even on Windows )

一个相对较大的项目的主要原因是由点3创建的改进的交流。其他的则是不错的奖金。

其他回答

我喜欢Git,因为它实际上有助于在中大型团队中开发人员之间的沟通。作为一个分布式版本控制系统,通过它的推送/拉系统,它帮助开发人员创建一个源代码生态系统,这有助于管理在单个项目上工作的大量开发人员。

例如,假设你信任5个开发人员,并且只从他们的存储库中提取代码。每个开发人员都有自己的信任网络,从那里提取代码。因此,开发是基于开发人员之间的信任结构,其中代码责任由开发社区共享。

当然,在这里的其他答案中也提到了其他好处。

一些回答已经提到了这些问题,但我想明确说明两点:

1)有选择性提交的能力(例如,git add——patch)。如果您的工作目录包含多个不属于同一逻辑更改的更改,Git可以很容易地提交只包含部分更改的提交。对于Subversion,这是很困难的。

2)在不公开更改的情况下提交的能力。在Subversion中,任何提交都是立即公开的,因此是不可撤销的。这极大地限制了开发人员“尽早提交,经常提交”的能力。

Git不仅仅是一个VCS;它也是一个开发补丁的工具。Subversion只是一个VCS。

其他的回答很好地解释了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.

这一切都是关于做某事所需的易用性/步骤。

如果我在我的PC/笔记本电脑上开发一个项目,git会更好,因为它的设置和使用要容易得多。 合并时不需要服务器,也不需要一直输入存储库URL's in。

如果只有两个人,我会说git也更简单,因为你可以互相推拉。

一旦你超越了这一点,我就会选择颠覆,因为在这一点上你需要设置一个“专用”服务器或位置。

使用git可以像使用SVN一样做到这一点,但是git的好处被需要执行额外步骤来与中央服务器同步所抵消。在SVN中,你只需要提交。在git中,你必须先执行git commit,然后再执行git push。额外的步骤很烦人,因为你最后做了太多。

SVN也有更好的GUI工具的好处,但是git生态系统似乎正在迅速追赶,所以从长远来看我并不担心这一点。

来自SourceGear的Eric Sink写了一系列关于分布式和非分布式版本控制系统之间区别的文章。他比较了最流行的版本控制系统的优缺点。非常有趣的读物。 文章可以在他的博客www.ericsink.com上找到:

阅读差异 Git是版本控制工具中的C Git缺乏对不变性和DVCS最佳实践的尊重 DVCS和dag,第1部分 DVCS和dag,第2部分 DVCS和Bug跟踪 合并历史,dag和Darcs Git为什么这么快? Mercurial, Subversion和Wesley Snipes