On Mon, 29 Jul 2013 03:50:56 -0700 (PDT)
Andreas Dvorak <andreas.dvo...@googlemail.com> wrote:

> Hi Krishna,
> unfortunately that did not help. The output is the same.
> DATE_STAMP=$(date +%Y%m%d%H%M)
> LOG=/var/tmp/git.log
> echo "checkout $DATE_STAMP" >>$LOG
> cd /var/tmp/test2_clone
> git fetch origin

^^^ There has been `git checkout *` in your original message;
    what's the matter with this change?

> git push
> Enter passphrase for key '/home/user1/.ssh/id_rsa': 
> Counting objects: 5, done.
> Delta compression using up to 32 threads.
> Compressing objects: 100% (2/2), done.
> Writing objects: 100% (3/3), 293 bytes, done.
> Total 3 (delta 0), reused 0 (delta 0)
> remote: fatal: Not a git repository: '.'

My take on this is that when server-side Git process executes your
hook it sets several environment variables which affect the execution
of the hook script; when you run `git checkout` (or whatever else),
there's no such variables.
These variables are explained in [1], and the easiest way to see what
they are is to add something like

set >/tmp/hook.envvars

at the beginning of your hook script then perform push to trigger the
hook and examine the generated file.

And by the way, doing `git checkout *` in your script might not do
what you really mean: the asterisk will be expanded by the shell to
the list of files in the current directory, not passed to the
`git checkout` command as is to be interpreted by Git, so supposedly
you want to protect that character from being expanded by the shell.

1. https://www.kernel.org/pub/software/scm/git/docs/git.html

Instead of reinventing the wheel (what you appear to be doing) I'd just
google for git+web+deploy and study ready-made solutions.  Beleive me,
while Git developers are tireless in explaining that Git is not a
deployment tool, every second web developer disagrees and embarks on
exactly this task.  StackOverflow receives at least one question per
day asking about how to do web deployment with Git, so you're
definitely not the first, and the internets are abundant with
information on how to do this with various degrees of lameness, so I'd
do some recearch and try out various solutions.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to