11

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?

10
  • @Ray Toal Most teams will use a central git server to store their code , aren't they? Commented Aug 27, 2011 at 6:46
  • @Kim: Yeah. But sub-teams can interact with distributed control. A picture in my answer. Commented Aug 27, 2011 at 6:59
  • You've just described how a centralized model could be set up with git and the asked why this is different from a centralized model. Obviously this model isn't different, but you don't have to use git this way. Commented Aug 27, 2011 at 7:50
  • @Charles Bailey Are there different models which are commonly used in industry? Commented Aug 27, 2011 at 8:09
  • 2
    @Charles Bailey so which one is the most commonly used in industry, svn, cvs? Commented Aug 27, 2011 at 8:26

5 Answers 5

11

Short Answer

It is not different with client/server model except a local copy, so why is it called a "distributed" one?

In the diagram below alice and david can interact because the system is distributed.

Distributed Version Control

Distributed control

Notice how, say, alice and david can interact because each can act as a server.

Central Version Control

Central control

Here the dev team only interacts with the main server.


Long Answer

Traditionally speaking source control systems were designed as server-client setups, loosely speaking. So the repository was centrally located.

With git and Mercurial, the system is designed to put all users at equal footing. Everyone has the full repository with them. The control and repository in that way is distributed amongst it users.

Sign up to request clarification or add additional context in comments.

2 Comments

I have seen that diagram with in between sharing before, but how is this done?
If you think of a bigger scope than 5 people hacking on a proof-of-concept, more like 10 teams of 8 devs each contributing to a project consisting of many components, that only builds monolythic... wouldnt sharing branches and versions between devs without a central instance have the risk to end in chaos? I mean, continuous Integration and continuous automated tests demand that you somehow stay in sync with the latest greatest (central repo), so that certain standards are guaranteed (automated integrationtest, statCodeAnalysis, DocsAsCode builds etc).
8

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.

1 Comment

101 also highlighted another big benefit in his answer - the ability for sub teams to push to each other before pushing to a centralised repository.
3

Because your clone can be someone else's master, and you can push your clone towards any other repository. There is no need for a concept of one "true" master; you can run it as a distributed grid of repositories.

Comments

2

It is called distributed because every git working directory contains a full-fledged repository containing complete history of the tree. This also means that you actually do not need network access for development because your tree can essentially be the master tree.

Comments

1

Check out the definition of a distributed system and compare that to what Git does/allows to be done. I think there's a match. A client/server approach needs by definition one "definitive/reference copy" which is not the case with Git and similar.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.