1

I have a Jekyll theme that I want to clone from GitLab. So I clone the theme in my local directory.

Then I have a bunch of files I want to overlay (or modify) in that theme and I want to store those files seperately and not as part of the theme. This then gives me the option to either run my theme locally (where I require the theme installed), or as a remote theme, where I change the config and the theme gets pulled in remotely on GitLab (supposedly).

So, I'm trying to clone the theme, then overlay my files on top and it should run. And if I need to do a pull from the theme repos for fixes, I pull, and then again overlay my files on top.

But I'm not sure how I would do this with Git. Can anyone comment?

Ender
  • 1,652
  • 2
  • 25
  • 50
  • branch that never gets merged and always rebases? – Abel Aug 20 '21 at 00:23
  • Well, that doesn't seem like I can treat my code as I normally would like a separate repo and I always have to be mindful and not blow away the one it sits in, so there very much linked together. In a remote configuration, I just want to deploy my stuff w/o requiring the theme repo. – Ender Aug 20 '21 at 00:37
  • Other than branching, you could use a submodule, but because you can't clone just part of a repo and the altered files would need to replace ones in the sub, best to just copy what you need from both with a script. – Abel Aug 20 '21 at 00:57

2 Answers2

2

Well, that doesn't seem like I can treat my code as I normally would like a separate repo and I always have to be mindful and not blow away the one it sits in, so there very much linked together

That is a bunch of English words strung together at random, and no portion of that makes any sense. I want to make this very clear as to why I'm not taking them into account.

Given the above, and my general understanding of your original question, it seems rather trivial.

  1. You start by cloning the theme into your own repository in the master branch. Your repository now only has a bunch of commits from the remote repository.

  2. You create a branch off the top of master and call it additions. Now you drop in your changes and commit everything. Your repository now has two branches, master with the original code and additions with your code branched off the top of master. Keep working in this branch.

  3. At some later point, your remote theme repository releases updates and you want to integrate them into your own changed theme. You hard check out master again, and thus revert back to the state of the repository when you first got it, then get the new changes and commit them to your master. This should work trivially since you made no changes to the branch.

  4. Now you need to update the branch you actually care about, so you check out additions and merge master into it. Resolve any merge conflicts if any and commit. Work in this branch if you need to make additional changes, and go back to the previous step when you want to update the theme with any more changes.

Blindy
  • 65,249
  • 10
  • 91
  • 131
1

I found out that I can keep my code in a branch, and then separate that branch into it's own repository per this post ... How do I move a Git branch out into its own repository?

This allows me to keep the code in a state similar to how Jekyll handles remote themes, my code separate from the theme. I can then merge a branch of this repo back into a branch of the theme repo at a later time if testing locally.

Ender
  • 1,652
  • 2
  • 25
  • 50