After editing my old question a few times, I make a new one because it is a new question now.
In .git/hooks/post-update
I have:
echo \"a
EDIT
It looks like this is your problem:
pre-receive update post-receive post-update
These hooks can be run either in a bare or a non-bare repository. In both cases, the current working directory will be the git directory. So, if this is a bare repository called "/src/git/test.git/", that will be the current working directory -- if this is a non-bare repository and the top level of the working tree is "/home/mark/test/" then the current working directory will be "/home/mark/test/.git/".
In both cases, the following environment variable is set:
GIT_DIR
is set to ‘.’With a working tree, this is unexpectedly awkward, as described in Chris Johnsen’s answer that I linked to earlier. If only
GIT_DIR
is set then this comment from the git man page applies:Note: If
--git-dir
orGIT_DIR
are specified but none of--work-tree,
GIT_WORK_TREE
andcore.worktree
is specified, the current working directory is regarded as the top directory of your working tree.In other words, your working tree will also be the current directory (the ".git" directory), which almost certainly isn’t what you want.
You could try setting GIT_WORK_TREE=..
or GIT_WORK_TREE="$GIT_DIR/.."
inside the hook
But the file did not change!
Most likely it did. Perhaps only the lineending did, or there were whitespace changes that are ignored when viewing the diffs, but it did change. Git knows, because the SHA1 sum of the file content changed.
Are you using windows on either end?
Windows has a tendency to mess with the line-endings. See the core.autocrlf and related options: