Search code examples
gitdvcs

the nature of git distribution


If I do the following and only the following:

  1. Create a personal repo on my PC (lets call it A)
  2. Create a bare repo on a server (call it B)
  3. remote add the bare repo to the personal repo (i.e. remote add B to A)
  4. Clone B to a third computer (call this new personal repo C)

Now let us imagine that the server is destroyed so B no longer exists. In this scenario, if I push changes from A, can C still fetch those changes?

Or in other words does git push changes to remotes in a 'chained' manner, or do all remotes on a 'cluster' know about each other?


Solution

  • First of all, you never pushed any changes from A to B. So while A knows about B, B doesn't know anything about A nor does it contain any data from it.

    Pushing from A to B would work from A (since A knows about B). The data would end up in B. No matter how many other repos know about B, B won't push the changes further. Instead the other repos would have to pull them from B.

    If we assume that you pushed at least once from A to B and cloned to C, you could add C as a remote to A and then push to it. But C will never "magically" contain data that are pushed between the other repos. Data is only copied into a repo when someone pushes to it or pulls from somewhere.

    So for every operation, only 2 repos are ever involved.