为什么git被称为分布式源控制系统? [英] Why git is called a distributed source control system?

查看:117
本文介绍了为什么git被称为分布式源控制系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将代码提交到本地存储库后,每个程序员都会运行该命令。

  git push origin master 

将本地文件推送到某个远程服务器。
除了本地拷贝之外,它与客户/服务器模型没有区别,为什么它被称为分布式呢?

解决方案

CVS和SVN等工具提供了集中式存储库模型。每个人都将他们的更改提交给同一个中央存储库。每个提交者保留最新版本的中央存储库的副本。当他们提交更改时,他们会将该更改发送回主存储库。



这里的限制是您始终需要在本地存储库上拥有最新代码,需要更改的历史记录才能向服务器询问该信息。您也总是需要能够访问远程存储库以提交。



分布式SCN可以模拟此模型,但它提供了更多。每个提交者都有其自己的存储库,而不是只有一个中央存储库发送更改,该存储库具有项目的整个提交历史记录。您不需要连接到远程存储库,更改只会记录在本地存储库中。您仍然可以推送到中央存储库,但您不需要。



(来源:使用Git的语用版本控制 Travis Swicegood)



<这样做的一大好处是您可以随时在本地计算机上启动存储库。通常,当我开始一个新项目时,我会 git init 并立即开始提交更新。稍后,如果我决定要与另一位开发人员共享此项目,我可以轻松设置一个我们都可以访问的集中式存储库。或者它可能永远不会离开我的电脑,但我将拥有本地版本控制,并且可以轻松查看我的提交历史记录。



另一大优势(云计算可能不那么重要现在)是冗余。如果存储库的一个副本由于某种原因而丢失,其他任何存储库都将包含完整的历史记录,因此,自上次 push 之后,您可能会失去所有工作。



Wikipedia上有更多信息:分布式版本控制 a>



我还强烈推荐上面提到的关于Git的Pragmatic Programmers。


It seems after committing code to the local repository, every programmer will run the command.

git push origin master

to push the local file to a certain remote server. It is not different with client/server model except a local copy, so why is it called a "distributed" one?

解决方案

Tools such as CVS and SVN offer a centralised repository model. Everybody commits their changes to the same central repository. Each committer keeps a copy of the latest version of the central repository. When they commit changes they send that change back to the main repository.

The limitations here are that you always need to have the latest code on your local repository, and to see the history of changes you will need to ask the server for that information. You also always need to be able to access the remote repository to commit.

A distributed SCN can emulate this model, but it offers so much more. Instead of just having one central repository that you send changes to, every committer has their own repository that has the entire commit history of the project. You don't need to connect to a remote repository, the change is just recorded on your local repository. You can still push to a centralised repository but you don't need to.

(Source: Pragmatic Version Control using Git by Travis Swicegood)

One big benefit of this is that you can start a repository at any time on your local computer. Generally when ever I start a new project I'll git init and start committing updates straight away. Later on if I decide I want to share this project with another developer I can easily set up a centralised repository that we can both access. Or it might never leave my computer but I'll have local version control in place and can easily view my commit history.

Another big benefit (perhaps less so with cloud computing now) is redundancy. If one copy of the repository is lost for whatever reason, any of the other repositories will contain the complete history so you could only potentially lose any work since your last push.

There's some more information on Wikipedia: Distributed revision control

I'd also highly recommend the above mentioned Pragmatic Programmers book on Git.

这篇关于为什么git被称为分布式源控制系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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