Jump to content

Template reuse using git worktrees


elabx
 Share

Recommended Posts

Hi everyone!

I'm developing multiple sites that use the same codebase for templates. I am using git branches to take control of the changes on each branch (one branch per site, each template folder is a different worktree with the branch checked out) and push the changes to other branches when necessary. So far this has proven to be very useful. But now I come to get some thoughts,opinions, answers.. :)

Now, I want to be able to do this:

Let's say current page uses mytemplate.php. If custom.mytemplate.php exists, use it instead. this way, I can .gitignore custom.* and still have the flexibility to apply custom changes to every site that translate to other branches, sacrificing tracking the customizations on each branch due to the .gitignore, but that also simplifies the merging on other branches (for updates that have to translate everywhere)

  • Do you think I could have a better approach for keeping track of customizations, maybe just be more carful on the merges when pulling changes?
  • Could the "template swap if alternate file exists" thing get done in a Hook?

Any other opinions or experiences doing a similar thing would be appreciated.

  • Like 1
Link to comment
Share on other sites

One idea that may work is

having a base branch with all the customizable and not customizable templates.

here you make any changes that should be propagated to the other branches.

 

Then when you need to customize a file you simply change to the desired branch,

merge the changes from the base branch and then modify any specific configuration for the file needed in the branch.

 

production_branch.png

 

See gitlab flow for more details https://docs.gitlab.com/ce/workflow/gitlab_flow.html

?

 

 

 

Link to comment
Share on other sites

Thanks for the suggestion! Sooo, what I have to do is keep order haha, cause right now I've been making pulling changes from branch to branch, or to master. I guess I have to limit myself to a one way flow.

Version control != Project management :D

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...