Is it possible to add a git submodule that you modified localy but of which you are not the owner and therefore can not push to remote. Currently my repo only adds a link to the original submodule, but without my modifcations to it. But i want the full content including my modifications to be pushed to my remote repo.
I did the following so far:
cd my_repo
git submodule add git@mygithost:submodulue submodule
git submodule init && git submodule update
cd submodule
<changes, hacks>
git commit -am 'modify submodule'
cd .. && git status
> On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: submodule (untracked content)
no changes added to commit (use "git add" and/or "git commit -a")
You cannot do that exactly because you cannot push your local changes to the original submodule. But you can work around the problem by forking the submodule.
First, fork
git@submodulehost:submodulue
togit@mygithost:submodulue
. If you cannot fork it directly at thesubmodulehost
clone and push: create a new empty repositorygit@mygithost:submodulue
and doThen use the fork as the source for your submodule:
Fix the code and push it to your fork: