1

I have a project repo (the parent) that contains a submodule (the child).

While working in the parent, I have made changes to the files of the child. I've committed those changes in the parent.

How do I get those changes back over to the child?

Bob Rockefeller
  • 4,492
  • 2
  • 28
  • 35

1 Answers1

1

You need to add a commit your changes in the child submodule folder, where you can also git push back to its own upstream repo.

Then you go back to the parent, add and commit the new gitlink (special entry in the index, referencing the new SHA1 of the submodule), and push.

After discussion, the OP mentions:

/Users/bob/Documents/Web Development/Projects/materialize is a public available theme for the Grav open source CMS.
/Users/bob/Sites/www.materialize.dev is the development version of a private website that uses the theme.

I can't add, commit, and push from the child because edits made in the parent's folder structure do not show as changes in the child, and so there's nothing to commit.
My objective is to develop the website (parent) as a way to develop the theme (child). So I edit in the parent. The theme is published as a complete package on GitHub, the website is not. Am I going about this all in the wrong way from the start?

I do mention that a submodule should be able to ignore what the parent repo is doing (it is simply referenced by said parent repo at a fixed commit).
So the current structure might not be a good fit for the type of development the OP is after.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • When I edit a file belonging to the child from within a folder in the parent, the parent recognizes the change and I can make a commit to the parent. But the child doesn't show any changes in its working directory, so I don't have the opportunity to make a commit there. – Bob Rockefeller Jan 15 '18 at 12:22
  • @BobRockefeller Then it is not a submodule: does the parent repo have a .gitmodules? – VonC Jan 15 '18 at 12:27
  • I'm convinced that it is a submodule. I created it with the Mac git client Tower and it shows as a submodule in the .gitmodules file. – Bob Rockefeller Jan 15 '18 at 12:28
  • So how about doing a commit from within the submodule itself, and pushing from there, before doing the same commit in the parent and pushing? (that is what I am describing in my answer) – VonC Jan 15 '18 at 12:31
  • The submodule's working directory is clean. It sees no changes to commit. :( – Bob Rockefeller Jan 15 '18 at 12:32
  • @BobRockefeller When you are pushing your main repo to a remote Git hosting service (for instance GitHub), do you see a gray folder as in https://stackoverflow.com/q/36684556/6309? – VonC Jan 15 '18 at 12:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/163186/discussion-between-bob-rockefeller-and-vonc). – Bob Rockefeller Jan 15 '18 at 12:34