简体   繁体   English

使用Git或Hg,如果整个团队使用来自中央服务器的pull and push,它与SVN有什么不同?

[英]Using Git or Hg, if the whole team is using pull and push from a central server, how is it different from SVN?

Say, if the whole team using Git or Mercurial is doing: 比如,如果整个团队使用Git或Mercurial正在做:

(example in Mercurial (Hg)): (例如Mercurial(Hg)):

hg pull
hg update

  [edit files or add files, and test]

hg add .
hg commit -m "good"
hg push

I don't see how it is different from using SVN? 我不知道它与使用SVN有何不同? If the team never push or pull to another member, but just pull and push to a central server. 如果团队从不推送或拉到另一个成员,而只是拉动并推送到中央服务器。 (unless if we say merging is better, but merging is the job of SVN or Git/Hg, just depends how well a job they do it, but not dependent on whether it is a DVCS (Distributed Version Control System)). (除非我们说合并更好,但合并是SVN或Git / Hg的工作,只取决于他们做的工作有多好,但不取决于它是否是DVCS(分布式版本控制系统))。 Is that true? 真的吗?

One difference is that you don't have to push every time you commit. 一个区别是您不必每次提交都要推送。 For instance I often commit several groups of changes during a day of coding, and then push once at the end of the day. 例如,我经常在编码的一天内提交几组更改,然后在一天结束时推送一次。

With Subversion each person only has a single revision of repository on their local machine at a given time, they cannot view revision history or rollback to a previous revision without connecting to the central repository. 使用Subversion,每个人在给定时间只在其本地计算机上拥有一个存储库版本,他们无法在不连接到中央存储库的情况下查看修订历史记录或回滚到以前的版本。 With Git and Mercurial, each person has a complete copy of the repository, and thus can do all of the above locally without needing to connect to the central repository. 使用Git和Mercurial,每个人都拥有存储库的完整副本,因此可以在本地执行上述所有操作,而无需连接到中央存储库。

Git and Mercurial need only connect to the repository to push up locally made commits and fetch commits not yet in the local repository. Git和Mercurial只需要连接到存储库来推送本地提交的提交并获取尚未在本地存储库中提交的提交。 Subversion cannot function at all without a connection to the central repository. 如果没有与中央存储库的连接,Subversion根本无法运行。

I think your statement is generally true and at the same time can have a lot of different answers. 我认为你的陈述通常是正确的,同时可以有很多不同的答案。

The DVCS gives you possibilities that are not possible with a central repository model like svn : DVCS为您提供了像svn这样的中央存储库模型无法实现的可能性:

  • When the server goes down, users still have the whole history and can work as if nothing happened. 当服务器关闭时,用户仍然拥有整个历史记录,并且可以像没有任何事情一样工作。
  • team members can share changes / branches between themselves without going through the central server. 团队成员可以在不通过中央服务器的情况下在他们之间共享更改/分支。
  • You can expose subset of your repository to different groups (let's say you have the latest and greatest feature you do not want exposed to outside contractors who still need to access 'a' repository with the same base code. 您可以将存储库的子集公开给不同的组(假设您拥有最新且最好的功能,您不希望向外部承包商公开,这些承包商仍然需要访问具有相同基本代码的'a'存储库。
  • A user can commit his changes into his local repository and keep it local until he is satisfied with it (and can possibly rework the history to make it cleaner before pushing) 用户可以将他的更改提交到他的本地存储库并保持其本地状态,直到他对它满意为止(并且可以在推送之前重新编写历史记录以使其更清洁)
  • In general, the fact that you have the whole repository locally make some operations more efficient, especially when looking at the log, comparing files in history...etc. 一般而言,您在本地拥有整个存储库这一事实可以提高某些操作的效率,尤其是在查看日志,比较历史记录中的文件等时。

And I am sure much more possibilities. 我相信更多的可能性。 It all depends really the environment you work in and what feature you may want to use. 这一切都取决于您的工作环境以及您可能想要使用的功能。

Yes, you can use DVCS exactly like centralized, and mostly all you will gain is speed, but taking full advantage of DVCS requires a change in the way you think about version control. 是的,你可以使用完全像集中式的DVCS,而且你获得的大多数都是速度,但是充分利用DVCS需要改变你对版本控制的看法。

A good question to ask is, "If I could have as many branches as I wanted, commit as often as I wanted, and only share those branches and commits with exactly whom I want, what would I do with it?" 一个很好的问题是,“如果我可以拥有我想要的尽可能多的分支,我可以随意提交,并且只与我想要的人分享这些分支和提交,我该怎么办呢?”

As an example of "as many branches as you want," I currently have around 5 branches just for me. 作为“尽可能多的分支”的一个例子,我目前只有5个分支机构。 One is the master branch I use for merges to share with colleagues. 一个是我用于合并与同事共享的主分支。 One is for the task I'm currently working on. 一个是我正在进行的任务。 One is for a previously finished task that I'm waiting for colleagues to review. 一个是我以前完成的任务,我正在等待同事审查。 Two are for longer-term tasks that I started, but had to postpone due to schedule priorities and will pick up again after the next release. 其中两个用于我开始的长期任务,但由于计划优先级而不得不推迟,并将在下一个版本之后再次启动。

As an example of the benefits of "commit as often as you want," a colleague today made a bunch of small changes from a static analysis tool, making about 15 local commits where only one would be done with CVCS. 作为“尽可能经常提交”的好处的一个例子,一位同事今天从静态分析工具中做了一些小改动,做了大约15个本地提交,其中只有一个用CVCS完成。 He accidentally introduced a serious bug that he didn't detect until he was done, but by using git bisect was able to quickly narrow it down. 他不小心引入了一个严重的错误,直到他完成后才检测到,但是通过使用git bisect能够快速缩小它。

As an example of "exactly whom I want," consider two developers working on a feature together. 作为“我想要的人”的一个例子,考虑两个开发人员共同开发一个功能。 They need to share frequently, but often what they share would break the main build. 他们需要经常分享,但他们分享的内容往往会打破主要构建。 With DVCS they can pull only from each other without sharing with everyone, and then check in a fully working feature in one cohesive push. 使用DVCS,他们只能在不与所有人共享的情况下相互拉取,然后通过一次紧凑的推送检查完全正常工作的功能。 Another example is the long-term task I had to postpone. 另一个例子是我不得不推迟的长期任务。 If my boss decides to hand that task to someone else who has freed up, I can easily give him my partially completed work with all its history. 如果我的老板决定将这项任务交给其他已经解雇的人,我可以轻松地将他的部分完成工作交给他所有的历史。

If your colleague changes one file, and commits the change, then you change another file without knowing about your colleague's commit, SVN will allow your commit, but Hg and git will not. 如果您的同事更改了一个文件并提交了更改,那么您在不知道同事提交的情况下更改了另一个文件,SVN将允许您的提交,但Hg和git不会。 This is by design because hg and git track the state of your entire repository, whereas SVN tracks changes to individual files and folders. 这是设计原因,因为hg和git跟踪整个存储库的状态,而SVN跟踪对单个文件和文件夹的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM