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.

  • When I enter ssh-keygen -t rsa -C “your@email.com” in git it gives “Too many arguments” error
  • .gitignore wildcard not working? (“LIVE-* ” pattern doesn't match “LIVE-vhost” filename)
  • Laravel 5 packages, how to develop over?
  • Ansible git module rev-parse
  • Git submodule checkout error: “fatal: reference is not a tree”
  • git merge conflict saying deleted, but it's not
  • 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?

  • how to clear all files from the git from the “Changed but not updated:” list
  • Thinking Sphinx with Rails: should I include these files in my git push?
  • Local Git branch has diverged from origin following an interactive rebase
  • Tig: how to view project from first commit?
  • How can I integrate git and svn for TeamCity?
  • Linux Kernel sources modified on OSX right after clone
  • 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.

    Git Baby is a git and github fan, let's start git clone.