为什么我应该使用 git 而不是 svn?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/740053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:19:33  来源:igfitidea点击:

Why should I use git instead of svn?

svngitversion-control

提问by Jhonny D. Cano -Leftware-

I use to work with Visual Studio + C#, and have been using svn before, but not currently, so I want to put my code again on source's control.

我曾经使用 Visual Studio + C#,之前一直在使用 svn,但目前没有,所以我想再次将我的代码放在源代码控件上。

Recently I heard about git, and I have been reading the git wiki and thisand this, and I have read that there are no gui clients for git like TortoiseSvn, or at least, I haven't found'em.

最近我听说了 git,我一直在阅读 git wiki 和thisthis,并且我读到没有像 TortoiseSvn 这样的 git gui 客户端,或者至少,我还没有找到它们。

My questions are:

我的问题是:

  • What are the advantages of git over svn
  • Where can I find front ends easy to use for git.
  • Is there any plugin (ANKH like) for git working with Visual Studio?
  • Where else can I find resources for start with git?
  • git 相对于 svn 的优势是什么
  • 我在哪里可以找到易于用于 git 的前端。
  • 是否有任何插件(类似于 ANKH)用于 git 与 Visual Studio 一起工作?
  • 我还能在哪里找到开始使用 git 的资源?

采纳答案by David Schmitt

Here my personal experiences with git vs. svn:

这是我个人使用 git 与 svn 的经验:

  • Git vs. SVN:git tracks state, history and integrity of the source tree. SVN only tracks state.
  • Git 与 SVN:git 跟踪源树的状态、历史和完整性。SVN 只跟踪状态。

Especially when merging, git's extensive use of stored history (across renames and merges) comes handy to make much better informed decisions leading to less conflicts.

尤其是在合并时,git 对存储历史的广泛使用(跨重命名和合并)可以方便地做出更明智的决策,从而减少冲突。

Having a complete, cryptographically verifiable integrity chain through the repository helps build trust in the underlying systems, or detect when they fail. On the downside it can be complicated to create "clean" patches. Having a proper workflow helps.

通过存储库拥有完整的、可加密验证的完整性链有助于建立对底层系统的信任,或检测它们何时发生故障。不利的一面是,创建“干净”的补丁可能很复杂。拥有适当的工作流程会有所帮助。

Finally, git works locally by default, giving it a unbelievably huge boost in contrast to SVN which must go to the central repo for almost any operation.

最后,git 默认在本地工作,与 SVN 相比,它具有令人难以置信的巨大提升,SVN 几乎所有操作都必须转到中央存储库。

  • Software:See this question, there are several standalone GUIs for working with the repo, history browsers and shell extensions.

  • Studio Plugin:GitExtensionshas a Visual Studio 2005 and 2008 plugin.

  • Documentation:Start with the GIT User's Manual. There are more links to tutorials and books on git-scm.com.

回答by Konstantinos

There is a relevant questionconcerning tools for GIT similar to tortoise.

有一个关于类似于乌龟的 GIT 工具的相关问题

The advantages of GIT over SVN are discussed overand overso it's not something someone should elaborate here

GIT的SVN上的优势进行了讨论,并,所以它不是某个人应该在这里细说

And as for a Visual Studio plugin, i don't think there is, or will be one for quite some time. Maybe i am missing something here though.

至于 Visual Studio 插件,我认为没有,或者在很长一段时间内都会有。也许我在这里遗漏了一些东西。

Try herefor a good guide on how to get started with git in windows

在这里尝试获取有关如何在 Windows 中开始使用 git 的良好指南

As for my entirely personal taste and view, i continue to stick to svn based on my personal requirements of what i want from my version control and i consider svn to be in a whole other level of tool and community support. Also i consider svn very mature and that doesn't necesserily mean that git doesn't get the job done.

至于我完全个人的品味和观点,根据我对版本控制的个人要求,我继续坚持使用 svn,我认为 svn 处于完全不同的工具和社区支持级别。此外,我认为 svn 非常成熟,但这并不一定意味着 git 无法完成工作。

回答by Abizern

I don't want to hash over pros and cons of git vs svn but here is one simple set of comparisons :- Why Git is better than X.

我不想讨论 git 与 svn 的优缺点,但这里有一组简单的比较:-为什么 Git 比 X 好

Some good Git Resources:

一些不错的 Git 资源:

  1. Git Ready. A sort of blog with little posts on beginner, intermediate and advanced uses of git.
  2. Git Magic. A nice run through of what you can do.
  3. GitCasts screencasts- nothing like seeing it in action to help you understand it's power. Including the useful Git On Windowsscreencast.
  1. 准备好。一种关于 git 的初级、中级和高级用法的博客。
  2. 吉特魔术。很好地完成了你可以做的事情。
  3. GitCasts 截屏视频- 没有什么比看到它的实际效果更能帮助您了解它的强大功能了。包括有用的Git On Windows截屏视频。

Have fun!

玩得开心!

回答by Lucas Jones

TortoiseGit is available - just Google it (I can't remember the URL) And:

TortoiseGit 可用 - 只需谷歌即可(我不记得 URL)并且:

  • Being distributed, you don't need to be connected to a server all the time, just work locally and pushwhen you need to.

  • It is very quick and doesn't use much bandwidth

  • And, the classic, if it's good enough for Linus, it's good enough for you :)

  • 由于是分布式的,您不需要一直连接到服务器,只需在push需要时在本地工作即可。

  • 它非常快并且不使用太多带宽

  • 而且,经典,如果它对 Linus 来说足够好,那么它对你来说也足够了 :)

Update: Link to TortoiseGit

更新:链接到 TortoiseGit

回答by Stefano Borini

I haven't used git, but I used svn and bazaar (which is similar in philosophy to git), so I can answer you in general terms.

我没有用过git,但我用过svn和bazaar(哲学上和git类似),所以我可以笼统地回答你。

The advantage of the so called distributed version control systems (DVCS) is that the repo and the code are together on your machine, and you are not dependent on a remote repo for operations. Every developer has a "branch", his own copy of the repo to which he commits to. You can commit, revert, check previous revisions, without being connected to the net. Officiality of repository is granted by virtue of human agreement, not technical setup. In svn, you only have one repo, which is _the_repo_ you and all the other people commit to. In DVCS, you commit to your own repo, and another developer to his own repo, and each of you can push his modifications to the officially designed repo when he pleases.

所谓的分布式版本控制系统 (DVCS) 的优点是 repo 和代码一起在您的机器上,并且您不依赖于远程 repo 进行操作。每个开发人员都有一个“分支”,即他自己承诺的回购副本。您可以提交、还原、检查以前的修订,而无需连接到网络。存储库的正式性是通过人类协议而非技术设置授予的。在 svn 中,您只有一个 repo,即您和所有其他人承诺的 _the_repo_。在 DVCS 中,您提交自己的 repo,另一个开发人员提交他自己的 repo,并且你们每个人都可以在他喜欢的时候将他的修改推送到官方设计的 repo。

Another clear advantage is that operations in a DVCS are fast, blazing fast. svn becomes incredibly slow when you start having a lot of stuff in your repo. This can become annoying very soon.

另一个明显的优势是 DVCS 中的操作非常快。当你的 repo 中开始有很多东西时,svn 会变得非常慢。这很快就会变得烦人。

On the minus side, DVCS are more difficult to use, but you can use a DVCS as a centralized VCS if you want.

不利的一面是,DVCS 更难使用,但如果需要,您可以将 DVCS 用作集中式 VCS。

回答by bahrep

What are the advantages of git over svn

git 相对于 svn 的优势是什么

Before deciding whether to use Git or SVN, make sure that you fully understand your requirements and understand what Git and SVN provide and support. Unfortunately, there is a lot of unfair bias on Git and SVN topic, as far as I've recently discovered at http://svnvsgit.com/.

在决定是使用 Git 还是 SVN 之前,请确保您完全了解您的需求并了解 Git 和 SVN 提供和支持的内容。不幸的是,就我最近在http://svnvsgit.com/ 上发现的那样,Git 和 SVN 主题存在很多不公平的偏见。

Let me cite one of the answerers here (@Konstantinos):

让我在这里引用一位回答者(@Konstantinos):

The advantages of GIT over SVN are discussed over and over so it's not something someone should elaborate here

GIT 相对于 SVN 的优势被反复讨论,所以这不是有人应该在这里详细说明的

This question was asked nearly 7 years ago. But the topic is still kinda hot or warm at least. I've recently stumbled upon http://svnvsgit.compage and I was a bit frustrated to find out that indeed the most of Git and SVN comparisons and tests on the internet are based on some strange intel like the one about Mozilla repository being very large in SVN. This is simply not true and most of the points described in http://git.or.cz/gitwiki/GitSvnComparsionare unfair or wrong.

这个问题是大约 7 年前提出的。但至少这个话题仍然有点热或温暖。我最近偶然发现了http://svnvsgit.com页面,我有点沮丧地发现互联网上的大部分 Git 和 SVN 比较和测试确实基于一些奇怪的情报,比如关于 Mozilla 存储库的情报在SVN中非常大。这根本不是真的,http://git.or.cz/gitwiki/GitSvnComparsion中描述的大部分观点都是不公平或错误的。

Or here is a quote of @DavidSchmitt (one of the answerers):

或者这是@DavidSchmitt(回答者之一)的引用:

Git vs. SVN: git tracks state, history and integrity of the source tree. SVN only tracks state.

Git 与 SVN:git 跟踪源树的状态、历史和完整性。SVN 只跟踪状态。

SVN and Git both ensure data integrity (SVN does it much better IMO). Both track history and state.

SVN 和 Git 都确保数据完整性(SVN 在 IMO 上做得更好)。既跟踪历史记录又跟踪状态。

The only real difference between SVN and Git is that Subversion is centralized and Git is decentralized. Subversion supports some concepts, workflows and cases Git can't support by design. At the same time, Git's disconnected nature can be a major benefits for someone.

SVN 和 Git 唯一真正的区别是 Subversion 是中心化的,而 Git 是去中心化的。Subversion 支持 Git 在设计上无法支持的一些概念、工作流程和案例。同时,Git 的独立性对某人来说可能是一个主要的好处。

Choose wisely!

做出明智的选择!

回答by Evan

I'm not sure what the stability of TortoiseGIT is at this stage, and when you're talking about something that integrates that intimately with Explorer this is an important consideration. Can anyone speak to this?

我不确定 TortoiseGIT 在这个阶段的稳定性如何,当你谈论与 Explorer 紧密集成的东西时,这是一个重要的考虑因素。任何人都可以谈论这个吗?

Also bear in mind that git is not the only choice if you are looking for the benefits of a distributed VCS. Git has the twin virtues of being very powerful and also very complicated. You might find another DVCS such as Bazaaror Mercurialan easier transition to reap the benefits of a distributed system. Both have tortoiseinterfacesin development but again, I'm not sure of their stability. (Bazaar's is included in their windows package though, so you would assume it is at a reasonably good stage.)

还要记住,如果您正在寻找分布式 VCS 的好处,git 不是唯一的选择。Git 具有非常强大和非常复杂的双重优点。您可能会发现其他 DVCS(例如BazaarMercurial)是获得分布式系统优势的更轻松过渡。两者都有开发中的乌龟接口,但同样,我不确定它们的稳定性。(尽管 Bazaar 包含在他们的 Windows 软件包中,因此您会认为它处于相当不错的阶段。)

A quick search has also turned up VisualHgand Bzr-VisualStudioalthough I have no idea of their readiness to be used in anger. Caveat emptor.

快速搜索也找到了VisualHgBzr-VisualStudio,尽管我不知道它们是否准备好在愤怒中使用。买者自负。

回答by Chris

Git appears to now be the industry standard for version control, replacing SVN and CVS etc. Git from a user perspective gives rise to more features and helps to manage code changes better than SVN will. It's also easier to set up repositories thanks to sites such as GitHuband BitBucketrather than needing your own server.

Git 现在似乎是版本控制的行业标准,取代了 SVN 和 CVS 等。从用户的角度来看,Git 带来了更多的特性,并且比 SVN 更好地帮助管理代码更改。由于有GitHubBitBucket等站点,而不需要您自己的服务器,因此设置存储库也更容易。

Git is easy to run in the command line (far more helfpul commands than SVN). There's also a range of good GUI programs which help to provide a nice front-end to your Git repo, GitHub Desktopand SourceTreeto name a couple.

Git 很容易在命令行中运行(比 SVN 多得多的 helfpul 命令)。还有一系列优秀的 GUI 程序有助于为您的 Git 存储库、GitHub 桌面SourceTree提供一个不错的前端。

回答by hoaphumanoid

As others had pointed out git is faster and more stable. It's distributed vs centralized, in svn if you mess the central repo you lose everything. In my experience there are less problems when you merge code with git.

正如其他人指出的那样,git 更快、更稳定。它是分布式 vs 集中式的,在 svn 中,如果你弄乱了中央仓库,你就会失去一切。根据我的经验,将代码与 git 合并时问题较少。

There is only one thing that I don't like. It's that you can't download a part of a repository with git. If you just need one folder, you'll need to download all the repo. You can do this with svn.

只有一件事我不喜欢。这是你不能用 git 下载存储库的一部分。如果您只需要一个文件夹,则需要下载所有存储库。你可以用 svn 做到这一点。