Reputation: 702
I am currently working on a github pages project and generate the website to a folder named dist
on a branch named dev
. I want to push the content of dist to the master branch. Googling around I found github subtree and I could push the dist
directory to master
using the command:
git subtree push --prefix dist origin master
issue is this pushes the entire directory. So master branch has one directory named dist
, containing dist/index.html
etc. Instead I would like to push all the content of dist to the master branch. So that the master branch contains index.html
and all other content. How can this be done?
Upvotes: 2
Views: 1063
Reputation: 1324577
It is not easily done (beside doing some git filter-branch
magic)
If you have a look at "Configuring a publishing source for GitHub Pages", you should instead generate your site directly in the gh-pages
branch.
Or, you can stay in master
branch, but generate in a docs/
folder instead of dist
.
In both cases, GitHub pages will render that content.
However, for a User Page:
If your site is a User or Organization Page that has a repository named
<username>.github.io
or<orgname>.github.io
, you cannot publish your site's source files from different locations.
User and Organization Pages that have this type of repository name are only published from themaster
branch.
In that case, reverse your workflow:
dev
branch,master
branchWhen you are in your dev
branch, you can declare the master
branch as a submodule (see here for the procedure), which will therefore be visible as a "subfolder" (for example a "dist
" subfolder, except that subfolder will actually be your same Git repo, on master
)
Generate your site as usual (in dist
), go in dist, add, commit and push (that subfolder being a submodule, it will push on its associated branch: master
)
Then go back to your project repo folder (parent of dist
, currently on the dev
branch), add, commit and push (to record the new state of the submodule dist
)
Upvotes: 2