Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: Pushing to a non-bare repository

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:52

Possibly related (same subject, not in this thread)

Steven Grimm [off-list ref] writes:
This keeps coming up as I introduce people to git. In previous
discussions, the conclusion often seems to be that users don't really
know what they want the semantics to be.
I do not think that was the conclusion.  My suggestion to you
would be to stop thinking as if push is a converse of pull
(because it is not; push is a counterpart of fetch), and leave
push as is.

In a typical mothership-satellite configuration, I would
recommend a workflow like this:

On Mothership:
	remote.satellite.url: satellite:project.git
        remote.satellite.push: refs/heads/master:remotes/mothership/master

On Satellite:
	remote.mothership.url: mothership:project.git
        remote.mothership.fetch: refs/heads/master:remotes/mothership/master

So when you happen to be on the mothership and you would want to
sync the satellite (because you are tired of working at your
office and would want to continue on your satellite notebook
sitting on the couch, relaxed), you would push:

	mothership$ git push satellite

Then you go to the satellite machine, and merge the mothership in:

	satellite$ git merge mothership

If you forgot to push before leaving the mothership, you do not
have to worry; you can initiate the transfer from the satellite:

	satellite$ git fetch mothership

and then do the same merge:

        satellite$ git merge mothership

Of course you could do "git pull mothership" to do the above two
as a single step, but the point is then the "patch flow" would
always be the same no matter from which side you initiate the
transfer from mothership to satellite.  The changes made on the
mothership will be done on 'master' branch on the mothership and
flow into remote/mothership/master on the satellite.  And you
will merge changes from the mothership to the satellite always
via remotes/mothership/master tracking branch.

To go the other way, you would further define these two:

On Mothership:
        remote.satellite.fetch: refs/heads/master:remotes/satellite/master

On Satellite:
        remote.mothership.push: refs/heads/master:remotes/satellite/master

and "git push mothership" from satellite, or "git fetch
satellite" from the mothership.

Another reason not to do what you described inside git-push is
that you do not need to -- I think you should be able to do all
that from your update (or post-update) hook.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help