1

working hard on configuration of my git repository, but stil no success.

Goal: as soon i make a push on my lokal repo, to the dev branch, it will merged with master brench.

post-update (hook)

#!/bin/bash
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".

LOGFILE=/www/htdocs/w00dac5d/_production/.git_push_log.tmp

&> $LOGFILE

echo 'push-start'

echo `basename $PWD`
#cd ../
#echo `basename $PWD`

git status
git checkout master

echo 'push-checkout'
git merge dev

exec git-update-server-info

getting errors like

"its not a git repo" but i check teh folder an it is the right one.

enter image description here

5
  • Check out stackoverflow.com/questions/2432026/… (with its comment), and see if you need to set GIT_DIR environment variable.
    – VonC
    Commented Jan 31, 2012 at 9:45
  • it is not really clear where to set it Commented Jan 31, 2012 at 14:28
  • I believe in your hook script, just to make sure Git knows where to look when you are making your git commands like git status: the current directory isn't the only thing that matter.
    – VonC
    Commented Jan 31, 2012 at 14:30
  • after cd ../ echo basename $PWD he is in _production, this is the git repo... Commented Jan 31, 2012 at 14:40
  • 1
    I would still recommend you try to set GIT_DIR to that .git directory full path (and GIT_WORK_TREE to the parent directory), to be extra sure. Test it and see of the errors persists.
    – VonC
    Commented Jan 31, 2012 at 14:43

1 Answer 1

2

The problem here is that in a post-update hook in a non-bare repository, GIT_DIR is set to . and your current directory is the .git directory. For such details for each different git hook, see this underrated blog post ;)

That means that if you do cd .. then GIT_DIR will still be . but your current directory will no longer be the .git directory. Try beginning your hook script with:

export GIT_DIR=/whereever/production/.git
export GIT_WORK_TREE=/whereever/production/

... to be safe - the rules about how GIT_DIR and GIT_WORK_TREE interact are fiddly.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.