Shubhanshu Mishra
Shubhanshu Mishra

Reputation: 6700

How to add master branch folder to github pages?

Hello I have a github repository where I am writing some code and making a folder which contains some HTML.

I have created a github page for my repo using github pages and which loads data from my README.md

So now I have 2 branches:

master gh-pages

My master branch has the following structure:

HTML/
IMAGES/
codeFiles.py
codeFile2.py
...

Is there any ways I can include just my HTML/ folder from my master branch into my gh-pages branch.

What I am looking for is a structure like of my gh-pages

Images/
Javascripts/
Styles/
HTML/
index.html
...

Upvotes: 0

Views: 306

Answers (1)

qqx
qqx

Reputation: 19475

Note I don't use gh-pages myself, so I haven't tried this exact scenario. If you do this I strongly advise doing it in a new clone of the repository and checking both branches thoroughly before pushing any changes.

You could do:

git checkout gh-pages
git read-tree master:HTML
git clean -df
git checkout .
git commit

All previous contents of the gh-pages branch would be removed in the new commit, replaced by the contents of the HTML directory from the current version of your master branch. This would not cause future changes to that content to be synced between those branches, but you could use the subtree merge strategy to merge changes to that shared content from the other branch:

git merge -s subtree $other_branch

But this isn't likely to work as well as merges typically do in git because those branches still don't share any history, only some of the content.

Upvotes: 1

Related Questions