I've seen other questions about this, but can't relate them to being the same.
I have a theme I've cloned from GitHub
, which becomes the master
branch.
Then I create a new local branch for my web page content within the originally cloned theme and I want to check my page content into my own repository on GitLab so I add remote repos for the content branch. At this point, the master remote is different from the branch remote.
By not merging my content branch into the master, I can always pull from the remote of the master which updates the web theme, and then switch to the content branch and develop/update my content. So they're kind of separate w/ no intent on merging.
The problem then becomes ... in order to run GitLab Pages
, the site is generated from the master branch. But I can't merge my content branch into the master branch 1) because the master has remote repos pointed elsewhere (original GitHub theme repo), and 2) if I could pull updates from the master, it would overwrite changes in my content branch.
So my requirements are that:
1) I can keep the remote theme seperate from my own content.
2) Add my own content to the theme and develop.
2) Join the theme and the content into a repo on GitLab for Pages to work.
3) Later update just the theme, and then overlay my content on the new theme and continue to develop.
Anyone have thoughts how to organize this properly?
CodePudding user response:
If I understand your situation correctly, publishing to your GitLab Pages requires pushing the publication-ready version onto your GitLab repo as master
.
In order to accomplish this, all you need to remember is that the master
branches on your GitHub and GitLab repos don't need to be related, even if you have a sandbox that points to both remotes, as you describe.
To create a local branch, let's call it publish
, that points to your GitLab's master
branch and distinguish it from your template's master branch on GitHub, you can do this:
git checkout develop
git checkout -b publish
git branch -u gitlab/master
Now, when you're on local branch publish
and have merged everything into it in the state your want it published, run git push
and it will update gitlab/master
with your local publish
branch.
Assumption:
You called your second remote, on GitLab, gitlab
, e.g., by running
git remote add gitlab URL_TO_YOUR_GITLAB_REPO