How do I properly set up hooks on a remote that is specified via the file:// protocol?

Say I’ve got an upstream repo (origin) that was added with

git remote add origin file:////

The repo.git is acually a windows shared folder where I and my dev colleagues have r/w access assigned.

Now, I want to set up a post-receive hook on that notifies Trac about freshly pushed revisions for automatic ticket updating. Basically, this is done by calling an executable on that does some work in the database there.

However, I notified that the hook for some reason doesn’t work.
So I’ve set up the hook to print everything she’s doing to D:/temp/post-receive.log and issued a git push in order to trigger the hook.

When I looked into D:/temp on, there was no logfile created.
Then, another question of me came into mind:
When actually the binaries of my machine are used for executing the hook, maybe also the paths of my machine are used. I looked into D:/temp and voilá, here we have the post-receive.log.

I traced the pwd to the logfile and it is not D:/repos/repo.git (what I expected) but actually is // Obviously the whole hook is executed in the context of the pusher’s machine and not in the context of the repo machine (

This is no problem for me since I have admin access to the remote machine and could use administrative shares in order to get my hook going (i.e. \\\D$\repos\repo.git etc). But this is an issue for my colleagues since they are plain users and no roots.

How do I set up my post-receive hook properly so that it works as expected?

How do I force my hook to be entirely run on the remote machine without using anything from my machine?

Do I really have to implement a real server hosting my repo? Or are there other ways that don’t need a server?

  • Embedding SVN Revision number at compile time in a Windows app
  • Git on Windows: Force use of OpenSSH
  • “no address associated with name” error when cloning's repo under Windows using ssh
  • Connect local git repos on windows and raspberry pi
  • How to configure to use the trusted certificate from the windows certificate?
  • Git CRLF for windows users
  • Windows, Git and Jenkins
  • Store files with Japanese characters in file name in msysgit
  • One Solution collect form web for “How do I properly set up hooks on a remote that is specified via the file:// protocol?”

    a post-receive hook is run after receiving data on the machine that is hosting the repository.

    now the machine that is “hosting the repository” is not the file-server where the actual packed-refs and other git database files are stored. (this file-server could be anything from a redundant cloud-based storage appliance to any old NAS-enabled “network disk”).

    Instead it is the machine that runs the “git frontend” (that is, the git commands that actually interact with the database).

    Now you are using a “network share” to host your (remote) git repository. For your computer (the client), this is just another disk device (like your floppy) and the git on your client will happily store database-files there, and run any hooks. But this is your computer, since it is being told to run the remote locally – simply because the file:// protocol does mean “local”.

    Btw, the fact that your remote is named is meaningless: this name is only there for you to keep track of multiple remotes, but it could be called instead.

    So there is no way to run any script on the file-server that happens to store some files names pack-refs and similar.

    If you want to have a git server to run hooks for you, you must have a git server first. Even worse: if you want a git server on machineX to run scripts on machineX, you must install a git server on machineX first.

    The good news: there is no need to “implement a real server”. Just install a pre-existing one. You will find docuementation about that in the Git Book, but for starters it’s basically enough to have git (for interaction with the database) and sshd (for secure communication via the network; and for calling git when appropriate) installed.

    Finally: i’m actually quite glad that you need to have software (e.g. a server) running on the remote end to execute code there. Just imagine what it would mean if copying some html files to your USB disk would suddenly spawn a web server out of thin air. Not to think of w32-virusses breeding happily on my linux NAS…

    Git Baby is a git and github fan, let's start git clone.