tags:

views:

64

answers:

4
+2  Q: 

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?

+4  A: 

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.

jpalecek
Uhm, a friend tried that. It does not work without some jumping through loops. You need at least a "central" repo on one of the machines, which both developers can use to push/pull to. Git 1.7+ even shows warninings when try to write to a non-bare repo.
ZeissS
@ZeissS: you'll get those warnings if you try to *push*. On the other hand, *pulling* works great. I cherry-pick changes from coworkers' repositories all the time.
Greg Hewgill
@zeiss, that works well without central repo. However , you can't indeed push something in a branch which is currently in use (so checked out on the "server" side). That's why a central repo works. Not because it's central , but because it doesn't checkout anything. If both developper , work on local branch and push thing on a remote one (which is not checked out by anybody ) that will work.
mb14
Ok, sumup: You cannot push to a repo, which has that exact branch you push to, checked out.
ZeissS
But you don't really need to push. The idea is that the person who is managing the actual release will pull from the other developers and that person's repo will be the canonical one. Needing more than one dev to push to a central repo implies misunderstanding of how Git is supposed to work.
siride
pulling is all that is probably need. I'll give the the direct access a shot and report back my findings.
dom farr
+1  A: 

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.

Greg Hewgill
Same network might also allow for ssh access - easier than `git-daemon` probably.
Jefromi
A: 

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.

mb14
A: 

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.

Bryce
The downside, and the part that I'm trying to avoid, is github will need housekeeping; each feature branch will need to be cleaned up, deleted, after its completion.
dom farr