Where's the "main" repo when using Git?

Sivaram said: “I have been using CVS on and off for a long time; so using git is a bit confusing.

If all the repo clones are equivalent, how does one know one is the ‘clean’ repo? On CVS, there is a centralized repo lying somewhere. I can’t seem to wrap my head around the decentralized model.”

This question trips up a lot of people when they’re introduced to the concept of distributed version control systems. But the answer is exactly the same as in the centralized world. It is wherever the project maintainers tell you it is. Let me give you an example:

If you were joining a new company or project that used SVN (or any centralized system) you’d come in and say “Hey, I’m new. Where’s the repo? ” and they’d respond, “We use SVN. The repo’s over there. Here’s the url.”

If you were joining a new company or project that used Git (or any other distributed system) you’d come in and say “Hey, I’m new. Where’s the repo?” and they’d respond, “We use Git. The repo’s over there. Here’s the url.”

See the difference? Neither do I. But in case you’re not convinced, consider the fact that at any point in time your sysadmin could move your SVN repo to another machine with a different URL. Everyone would change the URLs they connected to and that would be the end of it. The same thing applies in the distributed world.

Where your canonical repo lives, in any version control system, is nothing more than the place people happened to have agreed to keep it.

The only real difference is that in the distributed world you also have the option of pulling from non-cannonical repositories.

For a real world example we can look to Git itself. Where’s the main git repo? It’s where the Git homepage says it is. Compare this with Apache, which uses Subversion; their main repo is where their homepage says it is too. In both cases it might change tomorrow, but everyone would be really annoyed if it did so the people in charge are going to do their best to avoid it.

Sometimes people contributing to Git will send an e-mail to the list asking others to pull some feature from their personal repo (instead of just sending a patch). Some people pull, some people don’t. It really doesn’t matter. All that really matters is what changes get pushed to the main repo, just like in the centralized world.

Deciding what gets pushed to the main repo, or who gets to push to it is a project management decision that has very little, if anything, to do with what version control software you happen to use. Some systems enforce those business rules with software. Some don’t.