I have this simple hook on /hooks/post-update inside a bare repository:
#!/bin/sh
git-update-server-info
GIT_WORK_TREE=/home/user/apps/application-site/dev git checkout -f develop
GIT_WORK_TREE=/home/user/apps/application-site/dev git submodule update --init
GIT_WORK_TREE=/home/user/apps/application-site/master git checkout -f master
GIT_WORK_TREE=/home/user/apps/application-site/master git submodule update --init
The repository has some submodules, that I am expecting is pushing to production server, and checkout the two branches on two directories, so can I have later a dev.myapp.com for the development branch and http://www.myapp.com for the master branch, and all this updating also the submodules on the branches.
Checkout is working as expected, but not the submodule update –init, :'(
The remote output raises this errors.
remote: Switched to branch 'develop'
remote: You need to run this command from the toplevel of the working tree.
remote: Switched to branch 'master'
remote: You need to run this command from the toplevel of the working tree.
I am not quite sure what to do.
The answer is to do exactly what git is telling you, which is:
So do that. Here’s a sample
post-updatehook:This assumes that:
core.bareisfalsereceive.denyCurrentBranchisignore. You need this because otherwise you’ll get an error pushing into a repository withcore.bareset tofalse.…and seems to work in my limited testing.