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

我一直在使用Subversion几年,在使用SourceSafe之后 ,我只是喜欢Subversion。 结合TortoiseSVN ,我真的不能想象它会如何更好。

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

Git如何改进Subversion?

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.

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.

How does Git improve upon Subversion?

最满意答案

Git不比Subversion更好。 但也不会更糟。 这不一样。

关键的区别在于它是分散的。 想象一下,你是一名开发人员,您在笔记本电脑上开发,并希望拥有源代码管理功能,让您可以回到3小时。

使用Subversion,您有一个问题:SVN存储库可能位于您无法访问的位置(在您的公司,您目前没有互联网),您不能提交。 如果要制作代码副本,则必须直接复制/粘贴代码。

使用Git,你没有这个问题。 您的本地副本是存储库,您可以承诺并获得源代码管理的所有好处。 当您重新连接主存储库时,您可以对其进行承诺。

这首先看起来不错,但是请记住这种方法增加了复杂性。

Git似乎是“新的,有光泽的,酷的”的东西。 这绝对不是坏的(Linus为Linux内核开发写了一个原因),但是我觉得很多人都是因为它是新的,而且是由Linus Torvalds编写的知道为什么/如果它更好。

Subversion有问题,Git,Mercurial,CVS,TFS等等也是如此。

编辑:所以这个答案现在是一年前,仍然产生很多升华,所以我想我会补充一些解释。 在写自此以来的最后一年,Git获得了很大的发展和支持,特别是像GitHub这样的网站真的起飞了。 我现在使用Git和Subversion,我想分享一些个人见解。

首先,Git在开展分散化工作时,首先可能真的很混乱。 什么是遥控器? 以及如何正确设置初始存储库? 是开始出现的两个问题,特别是与SVN的简单“svnadmin create”相比,Git的“git init”可以使用参数--bare和--shared,这些参数似乎是“适当”的方式来设置集中式库。 这有其原因,但增加了复杂性。 “checkout”命令的文档对于人们的改变是非常混乱的 - “正确”的方式似乎是“git clone”,而“git checkout”似乎切换了分支。

当您下放时,Git真的会发光。 我在家里有一台服务器和一台笔记本电脑,SVN在这里工作不好。 使用SVN,如果我没有连接到存储库,我无法进行本地源代码管理(是的,我知道SVK或有关复制repo的方式)。 使用Git,这是默认模式。 这是一个额外的命令(git commit在本地提交,而git push origin master将主分支推送到名为“origin”的远程)。

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

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

SVN具有以下优点:它更容易学习:如果您知道如何创建,提交和结帐,您的存储库,所有更改,您都可以随时取出分支,更新等功能。上。

Git的优点是,如果一些开发人员并不总是连接到主存储库,那么它更适合。 此外,它比SVN快得多。 而从我听到的,分支和合并支持是好多了(这是预期的,因为这是它写的核心原因)。

这也解释了为什么它会在互联网上获得如此多的嗡嗡声,因为Git非常适合开源项目:只需要将其更改为自己的Fork,然后请原始的项目维护者来提取更改。 使用Git,这只是工作。 真的,尝试在Github,这是魔术。

我还看到Git-SVN桥梁:中央存储库是一个Subversion repo,但开发人员在本地与Git一起工作,然后桥接器将其更改推送到SVN。

但是,即使这么长时间的补充,我仍然坚持我的核心信息:Git不是好或坏,它只是不同。 如果您需要“离线源代码管理”,并且愿意花一些额外的时间学习它,这太棒了。 但是,如果您有严格的集中式源代码控制和/或正在努力引入源代码管理,因为您的同事不感兴趣,那么简单和优秀的工具(至少在Windows上)的SVN闪耀。

Git is not better than 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.

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.

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 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 has Problems, but so does Git, Mercurial, CVS, TFS or whatever.

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. I'm using both Git and Subversion nowadays and I'd like to share some personal insight.

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

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

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

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.

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.

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更好?(Why is Git better than Subversion?)

我一直在使用Subversion几年,在使用SourceSafe之后 ,我只是喜欢Subversion。 结合TortoiseSVN ,我真的不能想象它会如何更好。

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

Git如何改进Subversion?

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.

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.

How does Git improve upon Subversion?

最满意答案

Git不比Subversion更好。 但也不会更糟。 这不一样。

关键的区别在于它是分散的。 想象一下,你是一名开发人员,您在笔记本电脑上开发,并希望拥有源代码管理功能,让您可以回到3小时。

使用Subversion,您有一个问题:SVN存储库可能位于您无法访问的位置(在您的公司,您目前没有互联网),您不能提交。 如果要制作代码副本,则必须直接复制/粘贴代码。

使用Git,你没有这个问题。 您的本地副本是存储库,您可以承诺并获得源代码管理的所有好处。 当您重新连接主存储库时,您可以对其进行承诺。

这首先看起来不错,但是请记住这种方法增加了复杂性。

Git似乎是“新的,有光泽的,酷的”的东西。 这绝对不是坏的(Linus为Linux内核开发写了一个原因),但是我觉得很多人都是因为它是新的,而且是由Linus Torvalds编写的知道为什么/如果它更好。

Subversion有问题,Git,Mercurial,CVS,TFS等等也是如此。

编辑:所以这个答案现在是一年前,仍然产生很多升华,所以我想我会补充一些解释。 在写自此以来的最后一年,Git获得了很大的发展和支持,特别是像GitHub这样的网站真的起飞了。 我现在使用Git和Subversion,我想分享一些个人见解。

首先,Git在开展分散化工作时,首先可能真的很混乱。 什么是遥控器? 以及如何正确设置初始存储库? 是开始出现的两个问题,特别是与SVN的简单“svnadmin create”相比,Git的“git init”可以使用参数--bare和--shared,这些参数似乎是“适当”的方式来设置集中式库。 这有其原因,但增加了复杂性。 “checkout”命令的文档对于人们的改变是非常混乱的 - “正确”的方式似乎是“git clone”,而“git checkout”似乎切换了分支。

当您下放时,Git真的会发光。 我在家里有一台服务器和一台笔记本电脑,SVN在这里工作不好。 使用SVN,如果我没有连接到存储库,我无法进行本地源代码管理(是的,我知道SVK或有关复制repo的方式)。 使用Git,这是默认模式。 这是一个额外的命令(git commit在本地提交,而git push origin master将主分支推送到名为“origin”的远程)。

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

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

SVN具有以下优点:它更容易学习:如果您知道如何创建,提交和结帐,您的存储库,所有更改,您都可以随时取出分支,更新等功能。上。

Git的优点是,如果一些开发人员并不总是连接到主存储库,那么它更适合。 此外,它比SVN快得多。 而从我听到的,分支和合并支持是好多了(这是预期的,因为这是它写的核心原因)。

这也解释了为什么它会在互联网上获得如此多的嗡嗡声,因为Git非常适合开源项目:只需要将其更改为自己的Fork,然后请原始的项目维护者来提取更改。 使用Git,这只是工作。 真的,尝试在Github,这是魔术。

我还看到Git-SVN桥梁:中央存储库是一个Subversion repo,但开发人员在本地与Git一起工作,然后桥接器将其更改推送到SVN。

但是,即使这么长时间的补充,我仍然坚持我的核心信息:Git不是好或坏,它只是不同。 如果您需要“离线源代码管理”,并且愿意花一些额外的时间学习它,这太棒了。 但是,如果您有严格的集中式源代码控制和/或正在努力引入源代码管理,因为您的同事不感兴趣,那么简单和优秀的工具(至少在Windows上)的SVN闪耀。

Git is not better than 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.

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.

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 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 has Problems, but so does Git, Mercurial, CVS, TFS or whatever.

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. I'm using both Git and Subversion nowadays and I'd like to share some personal insight.

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

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

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

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.

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.

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.