简体   繁体   中英

Github superproject shows changes when submodule updates?

I'm using Github Pages to host a user webpage and a Jekyll Now project webpage. Because of the way Github Pages assigns web addresses, the user webpage is located at username.github.io, while the project is assigned to username.github.io/blog.

I want the blog project to be able to access some files from the user webpage, such as styles.css. In order to facilitate relative file paths, I thought it would be a good idea to locally nest my blog project within my user webpage directory; that way the relative paths would be the same both on the web and on my local machine, meaning that the path "../styles.css" would let my blog project access the user webpage's CSS in all contexts.

To nest the projects, I simply made a local clone of the blog project within the local user webpage repository. Conveniently, the Github user webpage repository immediately recognized this /blog directory as a submodule. I've been doing some research and some tests to make sure that this arrangement results in the behavior I want, and so far everything has been perfect except for one confusing footnote.

I made a change within my local submodule and pushed it. Then without making any other changes, I staged, committed, and pushed my superproject repository using the following:

git add .
git commit -m "just a test"
git push origin master

I expected the push to fail because I hadn't actually made any changes in the superproject — the only change had been in the submodule. However, to my surprise the push worked.

When I analyzed the commit on Github, it showed a single change to the blog folder described as follows:

Submodule blog updated from 632f0e to e6a35d

My question: Did this push do anything that would functionally affect the way my projects/website works? Or is it just scribbling a comment that's only purpose is to be read by humans?

At this point I haven't found any functional differences, but I'm still new to Github, want to understand how things work, and am concerned that this might cause undesired behavior down the line.

It might be worth noting that I don't foresee this superproject depending on the submodule - rather, the submodule will depend on the superproject to get some of its styling.


Results that did not answer this question (perhaps because the questions were more complex than I could understand):

Git submodules act as normal repositories. The super repository will only see changes in the checked out commit of the submodule.

The changes you make are expected to be committed in the super repository, how else would it know which version of the submodule to use?

My question: Did this push do anything that would functionally affect the way my projects/website works? Or is it just scribbling a comment that's only purpose is to be read by humans?

Yes, your repository's submodule is pointing to a different commit. Cloning the repository would check the submodule to that new commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM