Friday, April 11, 2025

change submodule for a git repository

 When trying to build OpenSpace for ARM64, came across issues with webbrowser ext - CEF binary being downloaded was cef_binary_102.0.10+gf249b2e+chromium-102.0.5005.115_linux64.tar.bz2 while we need ...linuxarm64.tar.bz2 for ARM64

In this case, this file seems to be responsible - https://github.com/OpenSpace/OpenSpace/blob/master/modules/webbrowser/cmake/cef_support.cmake

which we can fork and modify. In general, for other submodules not present in the main repo, the procedure seems to be: 

How do I replace a git submodule with another repo? - Stack Overflow

If the location (URL) of the submodule has changed, then you can simply:

  1. Modify the .gitmodules file in the repo root to use the new URL.
  2. Delete the submodule folder in the repo rm -rf .git/modules/<submodule>.
  3. Delete the submodule folder in the working directory rm -rf <submodule>.
  4. Run git submodule sync. git submodule sync --recursive
  5. Run git submodule update.

More complete info can be found elsewhere:

Changing remote repository for a git submodule

If repo history is different then you need to checkout new branch manually:

git submodule sync --recursive
cd <submodule_dir> 
git fetch
git checkout origin/master
git branch master -f
git checkout master

And apparently with Git 2.25 (Q1 2020), you can modify it.

git submodule set-url -- <path> <newurl>

No comments:

Post a Comment