Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 'dev' branch.

I tried the following steps from within P:

  1. cd Vendor/Q
  2. git branch my-fixes
  3. git checkout my-fixes
  4. Make fixes
  5. git add
  6. git commit -m 'My fixes to 3rd Party Library Q'
  7. cd ../..
  8. git add Vendor/Q
  9. git commit -m 'Changes/fixes made to submodule Q'
  10. git push

However, this does not seem to solve my problem. Can someone help me out?

like image 391
kaushal Avatar asked Sep 06 '25 03:09

kaushal


2 Answers

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.

like image 116
linquize Avatar answered Sep 07 '25 17:09

linquize


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
like image 34
VonC Avatar answered Sep 07 '25 17:09

VonC