Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

svn - 为什么Git比Subversion更好?(Why is Git better than Subversion?)

I've been using Subversion for a few years and after using SourceSafe , I just love Subversion.

(我已经使用Subversion几年了,在使用SourceSafe之后 ,我只是喜欢Subversion。)

Combined with TortoiseSVN , I can't really imagine how it could be any better.

(结合TortoiseSVN ,我无法想象它会如何变得更好。)

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 .

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

How does Git improve upon Subversion?

(Git如何改进Subversion?)

  ask by community wiki translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Git is not better than Subversion.

(Git并不比Subversion好。)

But is also not worse.

(但也不会更糟。)

It's different.

(这不一样。)

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.

(想象一下,如果你是一名开发人员,你可以在笔记本电脑上进行开发,并希望拥有源代码控制,这样你就可以回到3个小时。)

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.

(使用Subversion,您遇到了一个问题:SVN存储库可能位于您无法访问的位置(在您的公司中,目前您还没有Internet),您无法提交。)

If you want to make a copy of your code, you have to literally copy/paste it.

(如果要复制代码,则必须逐字复制/粘贴它。)

With Git, you do not have this problem.

(有了Git,你没有这个问题。)

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 seems to be the "new, shiny, cool" thing.

(Git似乎是“新的,闪亮的,酷的”东西。)

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.

(这绝不是坏事(毕竟Linus为Linux内核开发编写了它的原因),但我觉得很多人跳过“分布式源代码控制”列车只是因为它是新的并且由Linus Torvalds编写,实际上并没有知道为什么/如果它更好。)

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

(Subversion有问题,但Git,Mercurial,CVS,TFS等也有问题。)

Edit: 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.

(在写这篇文章的最后一年,Git获得了很多动力和支持,特别是因为像GitHub这样的网站真的起飞了。)

I'm using both Git and Subversion nowadays and I'd like to share some personal insight.

(我现在正在使用Git和Subversion,我想分享一些个人见解。)

First of all, Git can be really confusing at first when working decentralized.

(首先,Git在分散工作时起初可能会让人感到困惑。)

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.

(一开始就出现了两个问题,特别是与SVN的简单“svnadmin创建”相比,Git的“git init”可以采用参数--bare和--shared这似乎是设置集中的“正确”方式库。)

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.

(“checkout”命令的文档对于转换的人来说非常混乱 - “正确”的方式似乎是“git clone”,而“git checkout”似乎可以切换分支。)

Git REALLY shines when you are decentralized.

(当你分散时,Git真的很棒。)

I have a server at home and a Laptop on the road, and SVN simply doesn't work well here.

(我家里有一台服务器,路上有一台笔记本电脑,SVN在这里效果不好。)

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).

(使用SVN,如果我没有连接到存储库,我就无法拥有本地源代码控制(是的,我知道SVK或者有关复制repo的方法)。)

With Git, that's the default mode anyway.

(使用Git,无论如何这都是默认模式。)

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 commit在本地提交,而git push origin master将master分支推送到名为“origin”的远程)。)

As said above: Git adds complexity.

(如上所述:Git增加了复杂性。)

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").

(创建存储库,checkout与clone,commit与push的两种模式......你必须知道哪些命令在本地工作,哪些命令与“服务器”一起工作(我假设大多数人仍然喜欢中央“主存储库” )。)

Also, the tooling is still insufficient, at least on Windows.

(此外,至少在Windows上,工具仍然不足。)

Yes, there is a Visual Studio AddIn, but I still use git bash with msysgit.

(是的,有一个Visual Studio AddIn,但我仍然使用git bash和msysgit。)

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.

(SVN的优势在于它更容易学习:如果您知道如何创建,提交和结帐,那么您的存储库,所有更改都会对您进行创建,提交和结帐,并且您已准备就绪,可以在以后进行分支,更新等操作。上。)

Git has the advantage that it's MUCH better suited if some developers are not always connected to the master repository.

(如果某些开发人员并不总是连接到主存储库,那么Git的优势在于它更适合。)

Also, it's much faster than SVN.

(而且,它比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).

(从我所听到的情况来看,分支和合并支持要好得多(这是预期的,因为这些是编写它的核心原因)。)

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.

(这也解释了为什么它在互联网上获得如此多的关注,因为Git非常适合开源项目:Just Fork it,将您的更改提交给您自己的Fork,然后让原始项目维护者提取您的更改。)

With Git, this just works.

(有了Git,这才有效。)

Really, try it on Github, it's magic.

(真的,在Github上尝试一下,这很神奇。)

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 Bridges:中央存储库是一个Subversion存储库,但开发人员在本地使用Git,然后桥接器将其更改推送到SVN。)

But even with this lengthy addition, I still stand by my core message: Git is not better or worse, it's just different.

(但即使有这么长时间的添加,我仍然坚持我的核心信息:Git不是更好或更糟,它只是不同。)

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.

(但是如果你有一个严格集中的源代码控制和/或正在努力引入源代码控制,因为你的同事不感兴趣,那么SVN的简单和优秀的工具(至少在Windows上)就会闪耀。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...