我正在开始一个新的分布式项目。我应该使用SVN还是Git,为什么?
当前回答
我可能会选择Git,因为我觉得它比SVN强大得多。有一些便宜的代码托管服务对我来说非常有用——你不需要做备份或任何维护工作——GitHub是最明显的候选者。
也就是说,我对Visual Studio和不同的SCM系统的集成一无所知。我认为与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中注册!)
一般的最终目标可能是相同的,但您不能以相同的方式使用它们,也不能解决相同类型的问题(在范围或复杂性方面)。
我可以扩展一下这个问题,并问Git在MacOS上是否运行良好吗?
回复评论:谢谢你告诉我这个消息,我一直期待着尝试一下。我会把它安装在家里的Mac电脑上。
这可以归结为:
你的发展是线性的吗?如果是这样,您应该坚持使用Subversion。
另一方面,如果您的开发不是线性的,这意味着您将需要为不同的更改创建分支,然后将这些更改合并回主开发线(Git称为主分支),那么Git将为您做更多的工作。
SVN是一个repo和许多客户端。Git是一个有很多客户端回购的回购,每个客户端都有一个用户。它是去中心化的,人们可以在本地跟踪自己的编辑,而不必将内容推送到外部服务器。
SVN的设计更加集中,其中Git基于每个用户都有自己的Git回购,这些回购将更改推回到中央回购中。因此,Git为个人提供了更好的本地版本控制。
同时,你可以选择TortoiseGit, GitExtensions(如果你在github上托管你的“中央”git库,他们自己的客户端- github for Windows)。
如果您正在寻求摆脱SVN,那么您可能需要对Bazaar进行一些评估。它是具有这种分布式元素的下一代版本控制系统之一。它不像git那样依赖POSIX,所以有原生的Windows版本,它有一些强大的开源品牌支持。
但您甚至可能还不需要这些特性。看看分布式vcs的特点、优点和缺点。如果您需要的不仅仅是SVN提供的功能,请考虑使用一个。如果您不喜欢,您可能希望坚持使用SVN(目前)的高级桌面集成。
重点是,Git是分布式VCS, Subversion是集中式VCS。分布式vcs比较难理解,但是有很多优点。如果不需要这些优点,Subversion可能是更好的选择。
另一个问题是工具支持。您计划使用的工具更好地支持哪种VCS ?
编辑:三年前我是这样回答的:
Git目前只能通过Cygwin或MSYS在Windows上运行。 Subversion从一开始就支持Windows。作为解决方案 对于Windows可能为你工作,可能会有问题,作为最 Git的开发人员在Linux上工作,没有可移植性 心灵从一开始。目前我更喜欢Subversion 在Windows下开发。几年后,这可能就无关紧要了。
现在世界发生了一点变化。Git现在在windows上有一个很好的实现。虽然我没有在windows上进行全面测试(因为我不再使用这个系统),但我很有信心,所有主要的VCS (SVN、Git、Mercurial、Bazaar)现在都有适当的windows实现。SVN的这一优势已经不复存在。其他要点(集中式vs.分布式以及工具支持的检查)仍然有效。
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别