1

I try to write a post-receive hook to build a static webpage, but the git submodule update --init command fails. The script runs successfully when not run by the hook.

 OUTPUT=$HOME/post_receive_out REPO=$HOME/repositories/personal/www_root.git WORKING_DIR=$HOME/hugo_web_temp WWW_DIR=/var/www/servers/levente.logonex.eu/pages echo -ne "This is the post receive hook. I am " > $OUTPUT whoami >> $OUTPUT rm -rf $WORKING_DIR git clone $REPO $WORKING_DIR git -C $WORKING_DIR submodule update --init hugo -s $WORKING_DIR/lev -d $WWW_DIR chmod -R a+r $WWW_DIR 

says:

fatal: not a git repository: '.'

For now I fixed it with this:

cd $WORKING_DIR git --git-dir $WORKING_DIR/.git --work-tree $WORKING_DIR submodule update --init 

found in Git submodule update from post-receive hook

3
  • What version of Git are you using on that server? Commented Aug 28, 2020 at 16:07
  • @VonC, I'm using git version 2.20.1 from Debian stable. Commented Aug 28, 2020 at 16:10
  • OK so above the 1.8.5 (stackoverflow.com/a/20115526/6309) required to use -C Commented Aug 28, 2020 at 16:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.