`wt merge` fails with submodule push error
Bug Report
Description
wt merge fails when the repository contains git submodules.
Steps to Reproduce
- Have a repo with git submodules
- Create a worktree and make changes in the worktree
- Run
wt merge <branch>
Error
✗ Can't push to local <branch> branch
The following submodule paths contain changes that can
not be found on any remote:
modules/<submodule-name>
Please try
git push --recurse-submodules=on-demand
fatal: Aborting.
fatal: the remote end hung up unexpectedly
Expected Behavior
wt merge should succeed. The submodule has no new commits and no local changes
(git status is clean, git log --oneline origin/HEAD..HEAD returns nothing).
Environment
- worktrunk version:
wt 0f0cb2a - git version:
git version 2.52.0 - OS:
nixos
Thanks for reporting this! I investigated the git push command that wt merge uses internally (in src/commands/worktree/push.rs):
ctx.repo.run_command(&[
"push",
"--receive-pack=git -c receive.denyCurrentBranch=updateInstead receive-pack",
git_common_dir_str.as_ref(),
&push_target,
])
This push targets the local .git directory (not a remote), but it doesn't pass --recurse-submodules=no, so git's push.recurseSubmodules config can interfere. The likely fix is adding --recurse-submodules=no to this push command, since submodule recursion is irrelevant for a local worktree-to-worktree ref update.
I wasn't able to reproduce the failure on git 2.53.0 / Linux — even with push.recurseSubmodules=check and on-demand explicitly set, the local push succeeds. Could you share a bit more about your setup?
- What's your
push.recurseSubmodulessetting? (git config --get push.recurseSubmodulesat both repo and global level) - Is the submodule using an SSH or HTTPS URL?
- Any relevant
.gitconfigsettings related to submodules?
That would help reproduce and validate a fix. A maintainer will also take a look.
Upon further inspection, unsetting submodule.recurse=true in the .gitconfig has fixed this issue for me however this might be something worktrunk might want to handle on its own so that the user doesnt have to change their git configs
Thanks for confirming! That makes sense — submodule.recurse=true causes git push to try recursing into submodules, which fails for the local worktree-to-worktree push that wt merge uses internally.
I've opened #1619 to fix this. It adds --recurse-submodules=no to the local push command and also protects the git reset --hard in the --no-ff path with -c submodule.recurse=false. Submodule recursion is irrelevant for both operations since they're purely local ref updates.