Git in a decentralised mode: do we have to add all remotes ? And how do I know which remote to pull from?

StackOverflow https://stackoverflow.com/questions/23650437

  •  22-07-2023
  •  | 
  •  

Question

I've always been using svn or git with a centralised organisation (with only one remote server, from which everybody pulls and to which everybody push).

And I'm wondering how does it work practically when we use git with a decentralised organisation.

Do everyone have to add all the others manually with git remote add .... ? Including that when the team of 20 devs, becomes a 21 dev team, everybody needs to add the new dev, and the new one has to add the 20 others?

My other question is how do we know where to push and pull? is there a system that checks the most advanced version in all the remote pc? And if I've done some work, I commit and then? Do I have to push?

Thanks a lot

Was it helpful?

Solution

Do everyone have to add all the others manually with git remote add ....

No, because it is done for you when you are cloning a remote repo.

The recommended workflow is to clone one "blessed" repo (similar to a centralized workflow), and pull/push from/to it.

http://git-scm.com/figures/18333fig0501-tn.png

A git status will indicate at all time if you have local commits to push.

Nothing prevents you t add the repo url of a colleague, in order to exchange directly with his/her repo, but the easiest workflow remains to keep one remote "origin" repo as the blessed one.

See more at "Distributed Git - Distributed Workflows", which illustrates more complex workflows:

http://git-scm.com/figures/18333fig0502-tn.png

Because Git allows you to have multiple remote repositories, it’s possible to have a workflow where each developer has write access to their own public repository and read access to everyone else’s.

This scenario often includes a canonical repository that represents the "official" project.
To contribute to that project, you create your own public clone of the project and push your changes to it.

Then, you can send a request to the maintainer of the main project to pull in your changes.
They can add your repository as a remote, test your changes locally, merge them into their branch, and push back to their repository

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top