gek0n gek0n - 11 months ago 84
Git Question

Git submodule commit

I have project

with it's own repository. Today i add existing project in my solution: copy all files from downloaded sources of new project
(not my repository), and set reference in VisualStudio (it compiles

Now i change something in copied
project and in my
project. Go to "Git Extensions" and found, that new project
included in my project
as submodule, as expected.

I commit all changes in local and origins for Foo. That i want to commit all changes in
, but i remember - it's not my project (i didn't clone it). I can commit changes only local. If i trying to pull changes it must be like "Pull request" to author of

What i need to do, that don't delete/recopy
project? I just need clone it from author repo, than change settings in copied folder with repo (change origin from author's to my), and commit changes to my origin.

How i can do this? Thanks.

Answer Source

If I may rephrase the question, it works out to:

  • I wrote a project ($mine) and chose to make some other project ($theirs) a submodule.
  • I then modified $theirs and committed these modifications to my copy of their repository.
  • I would now like to publish a copy of my repo ($mine) along with a link to my modified version of their project ($theirs + mods), but without publishing a copy of my modified-$theirs, since they have not yet incorporated my changes.

The answer is "this is not possible with submodules". Your submodule must point to a publicly-accessible repository containing the specific commit ID. You must therefore either wait until they have incorporated your changes, so that there is a commit in $theirs you can use, or else publish your own forked variant of $theirs, so that there is a public repository containing a commit you can use.

(Alternatively, you can abandon submodules, incorporating their code directly into your own repository, although this brings its own set of issues.)