'Push to deploy' post-receive hook that includes submodules?

Currently, I have a post-receive hook that contains:

git --work-tree=/served/data/location --git-dir=/this/bare/git/repo checkout -f

That worked great, until I wanted to include a submodule, which it just ignores.

  • Git - multiple working copies without bare copy in between
  • How can I remove trailing whitespace only on changed lines in a pre-commit git hook?
  • How do I use C headers from libgit2 without getting this error?
  • Undoing the merge in Git so that no commits from the other branch exist
  • Ignore symbolic links in .gitignore
  • How can I commit many new files with git gui without clicking each of it?
  • After a bit of reading, I thought I could simply add:

    git --work-tree=/served/data/location --git-dir=/this/bare/git/repo submodule update --init --recursive


    git-submodule cannot be used without a working tree

    Odd, since I’ve plainly supplied the same --work-tree as for the prior checkout, which worked fine.

    I’m using git version 2.7.4 on the server, and pushing with git version 2.11.0.

    As far as I can tell, this is the same issue as here, except that talks about something called ‘OpenShift’ that I’ve never heard of and am not using, so the answer doesn’t really help.

  • Make a shallow GIT repository less shallow
  • Ignore app/build in Android Studio 1.3+ in .gitignore
  • Able to recover a deleted branch using git tag
  • Version control for large php/mysql web application
  • Does a rebase prevent a pull request in Git? Any pitfalls?
  • Git submodule pull overwrite/discard any local changes
  • One Solution collect form web for “'Push to deploy' post-receive hook that includes submodules?”

    For some reason, the command needed to be run from inside the work tree, not the bare git directory, even though both arguments are supplied:


    git --work-tree=/served-data --git-dir=/bare-repo checkout -f
    cd /served-data
    git --work-tree=/served-data --git-dir=/bare-repo submodule update --init --recursive
    Git Baby is a git and github fan, let's start git clone.