git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Pushing to a non-bare repository

From
Junio C Hamano <junkio@cox.net>
Date
Feb 3, 2007, 03:26 UTC
Message-ID
<7vfy9ndiqp.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<45C3FB08.1020805@midwinter.com>
Steven Grimm <koreth@midwinter.com> 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.

Previous: Steven GrimmNext: Simon 'corecode' Schubert
Message 2 of 6 in “Pushing to a non-bare repository”
  1. Steven GrimmFeb 3, 2007
  2. Junio C HamanoFeb 3, 2007
  3. Simon 'corecode' SchubertFeb 3, 2007
  4. Junio C HamanoFeb 3, 2007
  5. Linus TorvaldsFeb 3, 2007
  6. Junio C HamanoFeb 3, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.