Describe the problem
I'd like to have a submodule checked out inside of my template but I don't find an easy way to do it.
It would be nice if this could be documented.
I suspect the below doesn't work because the changes are being made in the temp folder that is not the actual folder with .git in it
How would you suggest working around this?
Template
# ...
_tasks:
- command: |
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
PROJECT_ROOT=$(pwd)
if [ ! -f "$PROJECT_ROOT/.gitmodules" ] || ! grep -q "my_submodule" "$PROJECT_ROOT/.gitmodules"; then
git -C "$PROJECT_ROOT" submodule add --force git@git.internal.com:my_submodule.git .my_submodule
fi
if git -C "$PROJECT_ROOT" submodule status | grep -q -e "^-"; then
git -C "$PROJECT_ROOT" submodule update --init --recursive
fi
git -C "$PROJECT_ROOT/.my_submodule" checkout tags/v1.0.10
# ...
To Reproduce
No response
Logs
#...
Reactivating local git directory for submodule '.my_submodule'
HEAD is now at 517672c Merge branch 'bump-ruff-0157' into 'master'
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: cannot change to '/private/var/folders/n_/1mvxkf8n6b5_vqjw6_1_y81r0000gp/T/copier._main.new_copy.zrqestmy/.my_submodule': No such file or directory
Task '<snipped command above>' returned non-zero exit status 128.
Expected behavior
It would be amazing if I could just specify the submodule and the tag to check out in the yaml, otherwise a way to run commands in the real dir would be nice.
Screenshots/screencasts/logs
No response
Operating system
macOS
Operating system distribution and version
macos 26.4.1
Copier version
copier 9.14.3
Python version
cpy 3.13
Installation method
uvx+pypi
Additional context
No response
Describe the problem
I'd like to have a submodule checked out inside of my template but I don't find an easy way to do it.
It would be nice if this could be documented.
I suspect the below doesn't work because the changes are being made in the temp folder that is not the actual folder with .git in it
How would you suggest working around this?
Template
To Reproduce
No response
Logs
Expected behavior
It would be amazing if I could just specify the submodule and the tag to check out in the yaml, otherwise a way to run commands in the real dir would be nice.
Screenshots/screencasts/logs
No response
Operating system
macOS
Operating system distribution and version
macos 26.4.1
Copier version
copier 9.14.3
Python version
cpy 3.13
Installation method
uvx+pypi
Additional context
No response