gek0n gek0n - 1 month ago 13
Git Question

Git submodule commit

I have project

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

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

I commit all changes in local and origins for Foo. That i want to commit all changes in
Bar
, 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
Bar
project.

What i need to do, that don't delete/recopy
Bar
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

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.)

Comments