Git hook for git worktree doesn't run "git submodule update --init --recursive" properly

19 views Asked by At

I have a hook in git worktree that is run every time I add a new branch with git worktree add <branch>. (I use the post-checkout hook and make sure it only runs when HEAD is 0, i.e it's a checkout not based on anything, so it only runs when I actually add a new branch with git worktree.)

The hook is a bash file. It simply looks like this:

`#!/bin/bash

...

git submodule update --init --recursive`

The problem I have is that, despite pwd being the correct folder, it will not run properly, instead of cloning into the submodules properly, it clones into (null)/submodule_name'.

So it looks like this: Cloning into '(null)/submodule_name'... for every submodule. I have the submodules directly under the working directory, not their own submodule folder.

If I simply go into the newly created branch and manually run git submodule update, it will properly clone into the correct folders for each submodule.

I've tried to script it to copy the incoming folders in the newly created (null) folder into the main folder, but since the git submodule update is happening incorrectly to begin with there's no correct data to paste into my main folder.

0

There are 0 answers