Modify URL of a nested submodule in git
I'm working with the latest version of ardupilot firmware. The goal is to make the ardupilot talking with a companion board using the mavlink protocol.
I started creating a fork of the original ardupilot repository on my github account.
The integration of the companion board would require me to modify also the code of some submodules of the ardupilot repository: PX4Firmware and mavlink.
Therefore, in order to be able to do it, I've forked also the various submodules of ardupilot on my github account.
Then, I've modified the .gitmodules file on my fork of the ardupilot repo, to be sure that the initialization of the submodules uses my forks instead of the original ones. The modification are as follows:
[submodule "modules/PX4Firmware"]
path = modules/PX4Firmware
url = git://github.com/MY_GITHUB_ACCOUNT/PX4Firmware.git
[submodule "modules/PX4NuttX"]
path = modules/PX4NuttX
url = git://github.com/MY_GITHUB_ACCOUNT/PX4NuttX.git
[submodule "modules/uavcan"]
path = modules/uavcan
url = git://github.com/MY_GITHUB_ACCOUNT/uavcan.git
[submodule "modules/waf"]
path = modules/waf
url = git://github.com/MY_GITHUB_ACCOUNT/waf.git
[submodule "modules/gbenchmark"]
path = modules/gbenchmark
url = git://github.com/MY_GITHUB_ACCOUNT/benchmark.git
[submodule "modules/mavlink"]
path = modules/mavlink
url = git://github.com/MY_GITHUB_ACCOUNT/mavlink
[submodule "gtest"]
path = modules/gtest
url = git://github.com/MY_GITHUB_ACCOUNT/googletest
After this, I realized that I need to modify the code of one submodule of the PX4Firmware as well. Therefore I repeated the same procedure within the PX4Firmware repo:
Modification of the .gitmodules file inside the PX4Firmware repo as follows:
[submodule "mavlink/include/mavlink/v1.0"]
path = mavlink/include/mavlink/v1.0
url = git://github.com/MY_GITHUB_ACCOUNT/c_library.git
[submodule "src/modules/uavcan/libuavcan"]
path = src/modules/uavcan/libuavcan
url = git://github.com/UAVCAN/libuavcan.git
[submodule "Tools/genmsg"]
path = Tools/genmsg
url = https://github.com/ros/genmsg.git
[submodule "Tools/gencpp"]
path = Tools/gencpp
url = https://github.com/ros/gencpp.git
[submodule "src/lib/matrix"]
path = src/lib/matrix
url = https://github.com/PX4/Matrix.git
[submodule "src/lib/DriverFramework"]
path = src/lib/DriverFramework
url = https://github.com/PX4/DriverFramework.git
[submodule "src/lib/ecl"]
path = src/lib/ecl
url = https://github.com/PX4/ecl.git
After modifying the files, I run the commands git submodule sync and git submodule update . I've also commited both .gitmodules files and pushed them to the corresponding master branches.
To see if it worked, I cloned my fork of the ardupilot on a new folder and initialized all the submodules recursively:
git clone https://github.com/MY_GITHUB_ACCOUNT/ardupilot.git
cd ardupilot
git submodule update --init --recursive
Unfortunately it didn't work as expected. While the submodules of my fork of ardupilot seemed to be downloaded from my github, the submodules of the PX4Firmware are still downloaded from the original repos.
Here you can find the output of the git submodule update --init --recursive command: https://pastebin.com/ECi4wQEZ
My problem is that I cannot commit on the original repositories, of course, therefore I have to work with forks to keep track of my modifications, as far as I understood.
I've found and tried many asnwers here on stackoverflow:
and many others, but none of them worked in my case.
Do you have any suggestions?
Thank you.
-------- UPDATE --------
In the meantime I've found a way to make it working.
I describe the procedure here in case someone needs it or knows a better way to do that:
I started solving the issue about the url of the sub-sub module: make sure that the PX4Firmware repo uses git://github.com/MY_GITHUB_ACCOUNT/c_library.git instead of the original one.
Here is the procedure:
From the main repository (ardupilot) I repeated the same procedure to make sure that the PX4Firmware submodule is the fork on my repository instead of the original one.
I'm sure there is a better way to do this. If you know it, please share. I also hope this can help somebody else with the same problem.
链接地址: http://www.djcxy.com/p/92324.html上一篇: 子模块项目死了,如何导入代码?
下一篇: 在git中修改嵌套子模块的URL