Alex Ionescu
Alex Ionescu

Reputation: 423

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?

Upvotes: 4

Views: 1981

Answers (2)

Abhay Saraf
Abhay Saraf

Reputation: 1212

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 https://github.com/vendor/proj-dep 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 https://github.com/vendor/proj-dep to https://github.com/alex/proj-dep 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).

Upvotes: 5

cs01
cs01

Reputation: 5781

The changes in the submodule need to be added/commited/pushed first, at the submodule level. Then at the super level you can simply add the folder and commit/push.

Upvotes: -1

Related Questions