2

I am currently using GitHub pages to build and host a personal website. However, I'm slightly put off by seeming lack of ability to develop subprojects individually while still seeing the result on the master branch.

To clarify, here's what I want to be able to do: In the repository root I have a landing page (index.html) and several subdirectories including some directories for global files (scripts, stylesheets, etc). Now, let's say I want to develop a project called "foo" - a web-application that will sit on mysite.github.io/foo. Is it possible for me to develop within the foo subdirectory/subproject without immediately committing to master (a la branches)?

I've done some research and discovered subtrees, but they do not work quite the way I want. Ideally (for my purposes), I would be able to develop within a subtree, make commits, and see the changes on my website, all while committing to the subtree's "master" branch instead of the main project's master branch.

Is such a thing possible, or am I stuck with dev branches that I can only test locally? (Local testing is certainly possible, I'm just looking to see if there's another option).

  • `mysite.github.io/foo` can be developed in the `gh-pages` of your repository `foo`. That's a "project site", in contrast to a "user or organization site", which you've described above. Does this meet your needs? It would be entirely separate from your user site; you imply that you'd like to use styles and scripts from your user site in your project site. – ChrisGPT was on strike Sep 13 '17 at 00:26
  • It might work as a live dev branch, but I'm looking for a solution that allows me to develop multiple subfolders independently. Thanks, though. – James Haller Sep 14 '17 at 00:07

1 Answers1

0

You could consider:

  • developping those different projects each in their own branch
  • adding those branches as submodules in your master branch (so the submodule refers to the same repo, simply a different branch)

See "Git - How to auto push changes in a directory to another branch" as an example.

That way, master references a fixed SHA1 of a given subfolder (which is the root folder of a submodule)

And you can add commits to a given branch (representing one of your project) without committing right away to master.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, @VonC. It looks like submodules will do what I want. New question: am I using subtree wrong or does it not actually function identically to submodules (the way I think it's supposed to)? – James Haller Sep 16 '17 at 06:19
  • @JamesHaller I describe the difference between submodule and subtree here: https://stackoverflow.com/a/31770147/6309. And give an example of subtree there: https://stackoverflow.com/a/24709789/6309. I prefer submodules, as I can reference a fixed point in history, allowing both branches to evolve at their own independent pace. – VonC Sep 16 '17 at 07:03
  • Yes, that was exactly the answer I was looking for! I'm never satisfied with "this is the answer", I always need to know why and -- although I still have to catch up on some jargon -- your explanations tremendously helped me to understand the difference in how they work and why a developer would choose one over the other. Thanks again! :) – James Haller Sep 17 '17 at 04:48