Alex Ionescu Alex Ionescu - 1 year ago 43
Git Question

Push git submodule changes to my own repo

I've just started using git submodules for my Android application by following this guide

I've successfully cloned the repo and changed a few things to suit the needs of my application, but I can't push those changes back to my repo.

git status
says there is modified content in my submodule, but I can't just
git add
that folder and push it?

If I try to push from the submodule directory it actually tries to push and gives me access denied since I'm not a contributor of that repo.

I want to be able to fetch the new changes from time to time, but to be able to keep and merge the small code that I modified every time that I try to update the submodule.

What would be the best approach in order to achieve this? Do I have to change the push remote origin?

Answer Source

From your question it seems that your submodule (say proj-dep) is technically an external library.

Let us say that the code of proj-dep is hosted at and you have mapped this path to your submodule.

However, you are not simply using proj-dep as is, you are using a modified version of the same.

You should be creating your own fork of to and map this second path to your submodule.

You will be able to push your own changes to this fork. Also, you can pull changes from vendor's proj-dep as and when needed and merge/rebase your fork (eventually pulling them down to your submodule path).