简体   繁体   中英

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
...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM