我正在开始一个新的分布式项目。我应该使用SVN还是Git,为什么?


当前回答

Git在Windows下还不受本地支持。它针对Posix系统进行了优化。然而,运行Cygwin或MinGW可以让你成功运行Git。

现在我更喜欢Git而不是SVN,但是如果你来自CVS, SVN的土地,它需要一段时间才能超过阈值。

其他回答

这是我在2009年9月删除Git vs. SVN的问题后,对一些重复问题的回答的副本。

更好吗?除了通常的WhyGitIsBetterThanX链接外,它们是不同的:

一个是基于分支和标记的廉价拷贝的中央VCS 另一个(Git)是基于修订图的分布式VCS。 参见VCS的核心概念。


第一部分产生了一些错误的评论,假装这两个程序(SVN和Git)的基本目的是相同的,但它们的实现却截然不同。 为了澄清SVN和Git之间的根本区别,让我重新表述一下:

SVN is the third implementation of a revision control: RCS, then CVS and finally SVN manage directories of versioned data. SVN offers VCS features (labeling and merging), but its tag is just a directory copy (like a branch, except you are not "supposed" to touch anything in a tag directory), and its merge is still complicated, currently based on meta-data added to remember what has already been merged. Git is a file content management (a tool made to merge files), evolved into a true Version Control System, based on a DAG (Directed Acyclic Graph) of commits, where branches are part of the history of datas (and not a data itself), and where tags are a true meta-data.

说他们没有“根本”不同,因为你可以实现同样的事情,解决同样的问题,是……在很多层面上都是错误的。

if you have many complex merges, doing them with SVN will be longer and more error prone. if you have to create many branches, you will need to manage them and merge them, again much more easily with Git than with SVN, especially if a high number of files are involved (the speed then becomes important) if you have partial merges for a work in progress, you will take advantage of the Git staging area (index) to commit only what you need, stash the rest, and move on on another branch. if you need offline development... well with Git you are always "online", with your own local repository, whatever the workflow you want to follow with other repositories.


然而,对那个旧答案(已删除)的评论坚持认为:

冯克:你混淆了执行上的根本差异(这种差异是非常根本的,我们显然都同意这一点)和目的上的差异。 它们都是用于相同目的的工具:这就是为什么许多以前使用SVN的团队能够相当成功地抛弃SVN,转而使用Git的原因。 如果他们不解决同一个问题,这种可替代性就不会存在。

,我回答说:

“可代换性”……有趣的术语(用于计算机编程)。 当然,Git并不是SVN的子类型。

您可以使用这两种工具实现相同的技术特性(标记、分支、合并),但是Git不会妨碍您,它允许您专注于文件的内容,而不用考虑工具本身。

你当然不能(总是)用Git替换SVN,“而不改变该程序的任何可取属性(正确性、执行的任务……)”。(引用了前面提到的可替代性定义):

One is an extended revision tool, the other a true version control system. One is suited small to medium monolithic project with simple merge workflow and (not too much) parallel versions. SVN is enough for that purpose, and you may not need all the Git features. The other allows for medium to large projects based on multiple components (one repo per component), with large number of files to merges between multiple branches in a complex merge workflow, parallel versions in branches, retrofit merges, and so on. You could do it with SVN, but you are much better off with Git. SVN simply can not manage any project of any size with any merge workflow. Git can.

同样,它们的本质是不同的(这会导致不同的实现,但这不是重点)。 一个将修订控制视为目录和文件,另一个仅看到文件的内容(以至于空目录甚至不会在Git中注册!)

一般的最终目标可能是相同的,但您不能以相同的方式使用它们,也不能解决相同类型的问题(在范围或复杂性方面)。

If your team is already familiar with version and source control softwares like cvs or svn, then, for a simple and small project (such as you claim it is), I would recommend you stick to SVN. I am really comfortable with svn, but for the current e-commerce project I am doing on django, I decided to work on git (I am using git in svn-mode, that is, with a centralised repo that I push to and pull from in order to collaborate with at least one other developer). The other developer is comfortable with SVN, and while others' experiences may differ, both of us are having a really bad time embracing git for this small project. (We are both hardcore Linux users, if it matters at all.)

当然,你的里程可能会有所不同。

我可能会选择Git,因为我觉得它比SVN强大得多。有一些便宜的代码托管服务对我来说非常有用——你不需要做备份或任何维护工作——GitHub是最明显的候选者。

也就是说,我对Visual Studio和不同的SCM系统的集成一无所知。我认为与SVN的集成会明显更好。

肯定是svn,因为Windows充其量是git世界中的二等公民(更多细节请参阅http://en.wikipedia.org/wiki/Git_(software)#Portability)。

更新:抱歉断开的链接,但我已经放弃尝试让SO与包含括号的uri一起工作。[链接现在固定。——编者)

我会设置一个Subversion存储库。通过这种方式,个人开发人员可以选择是使用Subversion客户机还是Git客户机(使用Git -svn)。使用Git -svn不能为您提供完整Git解决方案的所有好处,但它确实为单个开发人员提供了对自己的工作流的大量控制。

我相信Git在Windows上的表现会在相对较短的时间内达到在Unix和Mac OS X上的效果(既然你问了)。

Subversion为Windows提供了出色的工具,例如用于浏览器集成的TortoiseSVN和用于Visual Studio集成的AnkhSVN。