为什么 Git 比 Subversion 好? [英] Why is Git better than Subversion?

查看:31
本文介绍了为什么 Git 比 Subversion 好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Subversion 几年了,在使用 SourceSafe,我就是喜欢 Subversion.结合 TortoiseSVN,我真的无法想象它会如何变得更好.

I've been using Subversion for a few years and after using SourceSafe, I just love Subversion. Combined with TortoiseSVN, I can't really imagine how it could be any better.

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

Yet there's a growing number of developers claiming that Subversion has problems and that we should be moving to the new breed of distributed version control systems, such as Git.

Git 如何改进 Subversion?

How does Git improve upon Subversion?

推荐答案

Git 并不比 Subversion 好.但也不差.不一样.

Git is not better than Subversion. But is also not worse. It's different.

关键区别在于它是去中心化的.想象一下,您是一名在路上的开发人员,您在笔记本电脑上进行开发,并且想要进行源代码控制,以便您可以返回 3 小时.

The key difference is that it is decentralized. Imagine you are a developer on the road, you develop on your laptop and you want to have source control so that you can go back 3 hours.

使用 Subversion,您会遇到一个问题:SVN 存储库可能位于您无法到达的位置(在您的公司中,并且您目前没有互联网),您无法提交.如果你想复制你的代码,你必须从字面上复制/粘贴它.

With Subversion, you have a Problem: The SVN Repository may be in a location you can't reach (in your company, and you don't have internet at the moment), you cannot commit. If you want to make a copy of your code, you have to literally copy/paste it.

有了 Git,你就不会有这个问题.您的本地副本是一个存储库,您可以提交它并获得源代码控制的所有好处.当您重新连接到主存储库时,您可以针对它提交.

With Git, you do not have this problem. Your local copy is a repository, and you can commit to it and get all benefits of source control. When you regain connectivity to the main repository, you can commit against it.

这起初看起来不错,但请记住这种方法增加的复杂性.

This looks good at first, but just keep in mind the added complexity to this approach.

Git 似乎是新的、闪亮的、酷的"东西.这绝不是坏事(毕竟 Linus 为 Linux 内核开发编写它是有原因的),但我觉得很多人只是因为它是新的并且是由 Linus Torvalds 编写的而跳上分布式源代码控制"火车,实际上并没有知道为什么/是否更好.

Git seems to be the "new, shiny, cool" thing. It's by no means bad (there is a reason Linus wrote it for the Linux Kernel development after all), but I feel that many people jump on the "Distributed Source Control" train just because it's new and is written by Linus Torvalds, without actually knowing why/if it's better.

Subversion 有问题,但 Git、Mercurial、CVS、TFS 或其他任何东西也有问题.

Subversion has Problems, but so does Git, Mercurial, CVS, TFS or whatever.

所以这个答案现在已经有一年了,仍然会产生很多赞成票,所以我想我会添加一些更多的解释.自从写这篇文章以来的去年,Git 获得了很多动力和支持,尤其是像 GitHub 这样的网站真正起飞之后.我现在同时使用 Git 和 Subversion,我想分享一些个人见解.

So this answer is now a year old and still generates many upvotes, so I thought I'll add some more explanations. In the last year since writing this, Git has gained a lot of momentum and support, particularly since sites like GitHub really took off. I'm using both Git and Subversion nowadays and I'd like to share some personal insight.

首先,在去中心化工作时,Git 一开始可能真的很混乱.什么是遥控器?以及如何正确设置初始存储库?是一开始就出现的两个问题,尤其是对比SVN简单的svnadmin create",Git的git init"可以带参数--bare和--shared,这似乎是设置集中式的正确"方式存储库.这是有原因的,但它增加了复杂性.checkout"命令的文档对于转换的人来说非常混乱——正确"的方式似乎是git clone",而git checkout"似乎是切换分支.

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 将 master 分支推送到名为origin"的远程).

Git REALLY shines when you are decentralized. I have a server at home and a Laptop on the road, and SVN simply doesn't work well here. With SVN, I can't have local source control if I'm not connected to the repository (Yes, I know about SVK or about ways to copy the repo). With Git, that's the default mode anyway. It's an extra command though (git commit commits locally, whereas git push origin master pushes the master branch to the remote named "origin").

如上所述:Git 增加了复杂性.创建存储库的两种模式,签出与克隆,提交与推送……您必须知道哪些命令在本地工作,哪些与服务器"一起工作(我假设大多数人仍然喜欢中央主存储库").

As said above: Git adds complexity. Two modes of creating repositories, checkout vs. clone, commit vs. push... You have to know which commands work locally and which work with "the server" (I'm assuming most people still like a central "master-repository").

此外,工具仍然不足,至少在 Windows 上.是的,有一个 Visual Studio AddIn,但我仍然使用 git bash 和 msysgit.

Also, the tooling is still insufficient, at least on Windows. Yes, there is a Visual Studio AddIn, but I still use git bash with msysgit.

SVN 的优势在于它更容易学习:如果你知道如何创建、提交和检出并且你准备好开始并且可以选择分支、更新等内容,那么就有你的存储库,对它的所有更改等等.

SVN has the advantage that it's MUCH simpler to learn: There is your repository, all changes to towards it, if you know how to create, commit and checkout and you're ready to go and can pickup stuff like branching, update etc. later on.

Git 的优势在于它更适合某些开发人员并不总是连接到主存储库的情况.此外,它比SVN快得多.而且据我所知,分支和合并支持要好得多(这是意料之中的,因为这些是编写它的核心原因).

Git has the advantage that it's MUCH better suited if some developers are not always connected to the master repository. Also, it's much faster than SVN. And from what I hear, branching and merging support is a lot better (which is to be expected, as these are the core reasons it was written).

这也解释了为什么它在互联网上获得如此多的关注,因为 Git 非常适合开源项目:只需 Fork 它,将您的更改提交到您自己的 Fork,然后让原始项目维护者拉取您的更改.使用 Git,这很有效.真的,在 Github 上试试,太神奇了.

This also explains why it gains so much buzz on the Internet, as Git is perfectly suited for Open Source projects: Just Fork it, commit your changes to your own Fork, and then ask the original project maintainer to pull your changes. With Git, this just works. Really, try it on Github, it's magic.

我还看到了 Git-SVN 桥:中央存储库是一个 Subversion 存储库,但开发人员在本地使用 Git,然后桥将他们的更改推送到 SVN.

What I also see are Git-SVN Bridges: The central repository is a Subversion repo, but developers locally work with Git and the bridge then pushes their changes to SVN.

但即使添加了这么长的内容,我仍然坚持我的核心信息:Git 没有更好或更坏,只是不同而已.如果您需要离线源代码控制"并且愿意花一些额外的时间来学习它,那就太棒了.但是,如果您有一个严格集中的源代码控制和/或因为您的同事不感兴趣而一开始就努力引入源代码控制,那么 SVN 的简单性和出色的工具(至少在 Windows 上)会大放异彩.

But even with this lengthy addition, I still stand by my core message: Git is not better or worse, it's just different. If you have the need for "Offline Source Control" and the willingness to spend some extra time learning it, it's fantastic. But if you have a strictly centralized Source Control and/or are struggling to introduce Source Control in the first place because your co-workers are not interested, then the simplicity and excellent tooling (at least on Windows) of SVN shine.

这篇关于为什么 Git 比 Subversion 好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆