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

Re: git push from client is not updating files on server

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2012, 02:23 UTC
Message-ID
<7vpqcpp2s9.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAC0z1F9sBYCuv_HMCx1ryWLvxZKUcLPS1UUj80ihEesje+SKzg@mail.gmail.com>
Jerome Yanga <jerome.yanga@gmail.com> writes:
Show 13 quoted lines
> The project in Apache's DocumentRoot was created using the following command:
>
> "cd /var/www/git
> git clone --bare <non-bare working directory> <project>.git"
>
> Hence, I believe that is is bare.  Besides, it does not have .git
> folder.  I assumed that when I did this that the non-bare directory
> will also be updated when a push is performed via http.
>
> My objective is that I would like the developers to be able to push
> via http and these pushes will need to be reflected on the non-bare
> working directory as these directories will be used for automated
> tests.

So that <non-bare working directory> above is what you want to be updated when you update <project>.git?

More concretely, for example, you have say /srv/project/frotz and /var/www/git/frotz.git directories on that server. Perhaps the project may have started in the former:

	mkdir -p /srv/project/frotz
        cd /srv/project/frotz
        git init
        ... populate with the sources ...
        git add ...
        git commit
and then cloned to the other one
	cd /var/www/git && git clone --bare /srv/project/frotz frotz.git
I'll assume that is more or less the set-up you have.

Now, it depends on how the push goes to the latter one (I do not remember offhand if pushing over dumb http transport triggers hooks), but in general, you would install a post-update hook (read githooks manual page) in the latter repository, that gets triggered when it receives a push. The hook could do something like this:

	#!/bin/sh
        unset GIT_DIR
        cd /srv/project/frotz &&
        git pull --ff-only /var/www/git/frotz.git master &&
	: you can trigger automated test here if you want to &&
        make test

The above example goes to the repository with a working tree, pulls the latest change from the repository the user pushed into, and then runs the automated test.

Previous: Neal KreitzingerNext: Neal Kreitzinger
Message 11 of 15 in “git push from client is not updating files on server”
  1. Jerome YangaMar 6, 2012
  2. Ben TebulinMar 6, 2012
  3. Junio C HamanoMar 6, 2012
  4. Neal KreitzingerMar 6, 2012
  5. Neal KreitzingerMar 6, 2012
  6. Junio C HamanoMar 6, 2012
  7. Jerome YangaMar 6, 2012
  8. Neal KreitzingerMar 6, 2012
  9. Jerome YangaMar 7, 2012
  10. Neal KreitzingerMar 7, 2012
  11. Junio C HamanoMar 7, 2012
  12. Neal KreitzingerMar 7, 2012
  13. Holger HellmuthMar 7, 2012
  14. Jerome YangaMar 7, 2012
  15. Jerome YangaMar 30, 2012

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.