Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build into gh-pages branch from master branch

What I want to do: I am using github. I have two branches. Master and gh-pages. I have a unity3d project on my master branch. When I run it, it will generate a webpage. I want to display the contents of the webpage on the gh-pages branch.

I assume this means I have to share a folder between two branches of my repository. That seems nearly impossible.

Is there a right way to do this? My current solution is making two github projects and building from the first into the second. Then, I view the gh-page for the second. That seems very... extraneous. I should be able to do this all with one project.

like image 453
tavoe Avatar asked Dec 17 '12 00:12

tavoe


People also ask

How do I push master to GH page?

The command suggested git push -f origin master:gh-pages will push your local master branch to the gh-pages branch.

How do I push files into GH-pages?

On the upload page, you can drag-and-drop files and folders and they will be added to the repo. Go to the root directory of your Startup website code, select everything, then drag it to the page. It is better to use drag-and-drop than to use the choose your files link to select files from your computer.

How do I branch GH-pages?

app, change directory back to the parent folder, setup a "gh-pages" subfolder for your "gh-pages" branch and change directory into it. Clone your "grandmaster" repository into the "gh-pages" folder (this will clone in the "master" branch), checkout the "gh-pages" branch, list the files (should have "index. html" and ".


2 Answers

You can just clone your repository again within your working directory structure of the first repository. So locally, you have this folder structure:

project
|- .git/
|- .gitignore
|- (other project related files)
|- deploy/
   |- .git/
   |- (deployed files)

Both project and deploy are cloned repositories of your project; deploy has the gh-pages branch checked out. The outer .gitignore obviously lists deploy/, so the folder is ignored for the project.

Now, when deploying, you publish all the files into the deploy folder, then cd into it, do a git add ., git commit, git push and the generated files are deployed.

Obviously this will not give you an actual relation between your master and the gh-pages branch, but both will live completely independent of each other in the same repository.

like image 180
poke Avatar answered Sep 19 '22 07:09

poke


This is similar to the Jekyll workflow. Say unity3d content is generated into a folder called foo. Add foo to .gitignore then do this

git checkout master
<run unity3d>
git checkout gh-pages
git rm -qr .
cp -r foo/. .
rm -r foo
git add
git commit

Example

like image 26
Zombo Avatar answered Sep 23 '22 07:09

Zombo