2

I have forked some repo and tried inlining its submodule simply by removing its .git directory. This didn't work but it took a few patches for me to realise.

Removing a submodule has been covered here: How do I remove a submodule?

I've done this like so:

git rm -r --cached path/to/submodule
git add path/to/submodule
git commit -m "inlined submodule"

I'd like to rebase and move this patch earlier in the commit history (to the point where I forked the main repo). The problem is during the rebase I hit this error:

error: Your local changes to the following files would be overwritten by merge:
        every
        file
        in
        the
        submodule
Aborting
hint: Could not execute the todo command
hint: 
hint:     pick 1e012345 Commit message
hint: 
hint: It has been rescheduled; To edit the command before continuing, please
hint: edit the todo list first:
hint: 
hint:     git rebase --edit-todo
hint:     git rebase --continue
Could not apply

My guess is git submodule configs are somehow partially outside of the standard git versioning workflow so there's no way to treat this as a merge conflict and resolve it. I can fix individual patches but immediately hit the same problem for every cherry-pick in the rebase. Is there a better way to handle submodule conflicts?

# Workaround..
# Force the state for the next patch
git rm * # :O
git checkout next-patch -- .
git add -u
# Inline the submodule again
git rm -r --cached path/to/submodule
git add path/to/submodule
# Commit
git commit -C next-patch
# Remove next-patch from the todo list
git rebase --edit-todo

# Continue the rebase and repeat for every commit :(
git rebase --continue
jozxyqk
  • 16,424
  • 12
  • 91
  • 180

0 Answers0