user5157427 user5157427 - 1 year ago 65
Git Question

git with no centralized remote repository

Suppose we are 10 programmers on the project, working with git. Suppose we don't want to use remote internet (github) repository, and also not a remote network centralized git repository.

  • How can we now all synchronise?

  • Everyone has to declare other programmers' repository as a remote repository one after another?

Answer Source

If you do not want to use a dedicated server there is always the possibility of using one of the developers' local repository as the "origin" that every other developer clones.

This can easily be done with SSH:

  1. Set up an SSH server on the origin machine.
  2. Give every developer SSH access to the machine (either using individual accounts, or a shared account, e.g. "developer").
  3. Have each developer clone the repository from that machine.

Cloning via SSH can be done like this:

git clone my-account@origin-machine:/full/path/to/repo/.git

...where my-account is the user account, and origin-machine is the machine that holds the origin repository.

Now, each developer can fetch and push changes, thus synchronizing with each other via the origin machine.

In a similar manner you can synchronize with several different machines if you so wish, by setting up more SSH remotes, e.g:

git remote add machine2 my-account@machine2:/some/other/path/to/repo/.git
git fetch machine2
git push machine2 my-new-branch


However, there is a catch: By default you may not push changes to the branch that is currently checked out on the remote machine (git will warn you if you try to do so, and quite frankly you do not want to do it anyway). Hence, you will have to come up with a branching strategy that avoids such situations (e.g. having all developers work on separate feature branches rather than a common branch is a good start).

With that said, I would strongly recommend using a local dedicated server with a bare repository (it is typically always online, and you do not have the problems with checked out branches on the developer machine).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download