dom farr
dom farr

Reputation: 4181

git repositories

Git is distributed source control system, right. How to connect two developers without a centralized repository.

Our team uses Github and if two developers want to work on the same branch it seems that branch needs to be pushed to the remote before they both have access to it...or does it?

Can a developer pull from another developers local repository?

Upvotes: 2

Views: 222

Answers (4)

brycemcd
brycemcd

Reputation: 4513

If you're already using Github, then the easiest way to get both of you working on the same branch is to push/pull from Github continuously. Pushing / Pulling from each other's machines will get hairy quickly and result in a lot more headache down the road. Of course, you can use another in house server or set up a bare repo on one or both of your machines, but this will likely lead to an overly complex setup and cause a lot of extra time and effort in managing the source.

To get started between you (Dom) and another developer (we'll call him John) on the same branch, first create the branch on your local machine and push it up to Github:

#On Dom's machine:
git checkout -b cool_feature
git push origin cool_feature #assumes origin is github

#on John's machine:
git checkout -b cool_feature
git pull origin cool_feature

Now you both have the same copy of the repo on your localhosts. Develop at will and make sure both of you commit often and push the commits up to Github. Also, make sure you pull from Github often.

Upvotes: 0

Greg Hewgill
Greg Hewgill

Reputation: 992707

It depends on how well connected those two developers are. If you're working on the same machine, then you can pull directly from the other user's clone. If you're working on the same network, you can set up a simple server with something like git daemon.

If you're on separate networks behind firewalls and whatnot, then you can share changes using a shared common server. Or, you could email patches to one another using git format-patch and git am.

Upvotes: 1

mb14
mb14

Reputation: 22596

Yes, you need to use the git remote add ... command to add the each user repository visible to each user. Obviously, they need to be able to see each other computer. You might have to setup ssh or use a git daemon.

Upvotes: 0

jpalecek
jpalecek

Reputation: 47762

Can a developer pull from another developers local repository?

Yes. A readonly access (nfs, ssh, ...) to the repository (ie. the actual files in .git directory) of the other developer is sufficient. Or, if a developer installs a git server, others can pull from it.

I'm not counting the possibility of sending patches by mail.

Upvotes: 5

Related Questions