2

I currently update a website by pushing the git repository to a remote. The remote then has a post-receive hook which does

GIT_WORK_TREE=/var/www/html/ git checkout -f

I recently added a submodule in my repository from a different project. I would like to pull from this submodule post-receive.

.gitmodule

 [submodule "plugins"]
    path = plugins
    url = https://github.com/getpelican/pelican-plugins.git

(yes it's a pelican website, but that's irrelevant)

I imagine it's a matter of adding a git pull in the right place in the post-receive hook, but I'm not sure exactly where or how.

Arthur B.
  • 3,445
  • 3
  • 21
  • 24

1 Answers1

0

If you have configured your submodule to follow the latest commit of a branch (or make an existing submodule track a branch), all you need to add is:

GIT_WORK_TREE=/var/www/html/ git submodule update --remote

That will pull said branch from within the submodule.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250