Make changes to a git submodule and then add those into my main project
I have a git project P. Within my project P is a submodule Q that was cloned off a 3rd party library’s master branch.
P | - src - Vendor | - Q
I do not have permission to make push any changes to the 3rd party library’s remote repo.
I made some fixes in
Q and I now want those to be pushed into the
master branch of my project
P so my team members can use them too.
Currently I am developing on my ‘
I tried the following steps from within
git branch my-fixes
git checkout my-fixes
- Make fixes
git commit -m 'My fixes to 3rd Party Library Q'
git add Vendor/Q
git commit -m 'Changes/fixes made to submodule Q'
However, this does not seem to solve my problem. Can someone help me out?
3 Solutions collect form web for “Make changes to a git submodule and then add those into my main project”
If you push project P, no one will be able to get the commit from step 6, because you do not have permission to make push any changes to the 3rd party library’s remote repo.
Have you considered to create a repo to store your company’s changes to Q, instead of registering the submodule to 3rd party’s remote? So that you may save your changes to Q to your company’s server.
Considering you will integrate the two repo (Q and your project) together, without having to push back any fix back to GitHub Q repo (since Q is no longer updated on GitHub), you could:
- subtree merge the two repos together
- make your fixes
- push your project (complete with Q in it) back for your developers to use
An alternative to using submodules is git-subtree (not to be confused with the subtree merge strategy). Its key benefit over submodules is that Q becomes part of your P’s history and repo, while retaining the ability to push changes to Q back to the vendor. Also, users who don’t care where Q came from don’t even need to install git-subtree.
While git-subtree is not part of core git, it was recently merged into the main git distro, which makes it semi-official.