cellio: (Default)
Monica ([personal profile] cellio) wrote2022-03-06 08:50 pm
Entry tags:

help wanted (involves git)

Dear Brain Trust,

I have a technical problem that I'm a few clues shy of solving. Can you help?

I have a personal web site, which I built using an SSG called Yellow. I'm using a few of their extensions, most importantly Blog. The way you use Yellow is to download and unpack a ZIP file, download any extensions you want into that directory structure, and add your content (also into that directory structure). The source is on GitHub but they also give you these ZIP files.

Last summer I downloaded those ZIP files, unpacked them, started tweaking things, and added my own content. I never cloned their repositories; I just took the ZIP files. Eventually I figured out that the easiest way for me to deploy my site was to use GitHub: I created a private repository, into which I added my then-current versions of both the tooling and the content, and I update it as needed (for example to add this post).

Yes I now know this was the wrong way to go about it. Apparently we won't have gotten "send clue back in time" working in my lifetime.

Since then, they've made some updates that I would like to take advantage of. I want to update to the new version, incorporating the changes I made to the previous version (figure out what they were and how to apply them). And I want to figure out a better way to organize this so that the next upgrade is more straightforward.

I imagine that what I wanted to have done instead was to fork their repos, apply my changes, make a separate repo for my content, and (do magic here) so it all works together. I don't know what that magic is. I'd like to check my assumptions about this being a better approach. Is there some other way I should be managing this? Another way to think about it is that my project (my site) has GitHub dependencies (those other two repositories); I'm not familiar with how dependencies are typically managed.

I mentioned I'm using GitHub for deployment. More specifically: I make edits on my personal machine, commit and push, and then on the hosting server I pull and, wham, the site is up to date. There's no explicit build step and I'm not fussing with rsync. My "aha" moment was that git can already figure out what's changed and needs to be pulled, so why should I have to? I like this simplicity.

I have found the version of the blog extension I started from (thank you for explicit version numbering), so it is possible to identify the changes I made to the original.

Should I create new repos (or forks) from the previous version, apply my changes, get that working, and then try to do the upgrade from there? How should I manage the multiple git repositories so that everything ends up in the right places? There's one repo for the base system (yellow), one for all the extensions (which overlays the file structure of the base system), and then I need a place for my actual content. How do I do this?

metahacker: Close-up of a computer screen showing a linux terminal. (drwxrwxrwx)

[personal profile] metahacker 2022-03-07 11:01 pm (UTC)(link)
Part one:
Do you actually need the history and branches of the old repo? If not, it may be worth it to say, screw it, and make a new repo with the same files in it. (I.e., start fresh.)



Part two:
If you truly need separate repos that depend on each other, and you can't make that dependency using a package manager (i.e. import the upstream repos as packages in the downstream repo), the git-ish solution is submodules. Submodules have never worked right for me and have caused big heartache on a project in the past, but that was 8 years ago, so who knows.
mdlbear: blue fractal bear with text "since 2002" (Default)

[personal profile] mdlbear 2022-03-08 05:49 pm (UTC)(link)

You don't really need submodules in most cases. Make a separate repo for your content and either make a symlink to it or simply put it in a subdirectory, which you put in the .gitignore file one level up.

You can do the same thing with any extensions that have their own repo.

If you have a separate web server (i.e. you're not using GitHub Pages), make origin point to the bare repo on the web host, with a post-update hook to update the site. I should write this up properly, shouldn't I?