user5157427
user5157427

Reputation: 253

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.

Upvotes: 2

Views: 228

Answers (2)

m-bitsnbites
m-bitsnbites

Reputation: 1084

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

...etc.

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). The server does not have to be fancy - something as simple as a Raspberry Pi should suffice in a small team (there is a simple tutorial here).

Upvotes: 2

maxik
maxik

Reputation: 1123

I think you will get the point reading the official reference. For the sake of your time you should consider promoting one developer to an integration manager which holds himself the main repository.


Or, simple as is, setup an internal git server (bare repository, although I recommend using gitolite) which is what we do at work, backups and such stuff come for free there.

Upvotes: 0

Related Questions