Reputation: 135
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.
Upvotes: 7
Views: 3059
Reputation: 1219
I wanted to push my doxygen docs from master to gh-pages "easily."
I read similar solutions and my eyes glazed over.
My solution was:
This still requires manually running the update and committing, which might be a good thing if you are posting to the website only from specific builds.
Example (mostly comments) at: https://github.com/nekenyu/libBsdSockets/blob/gh-pages/update_doc.sh
Upvotes: 0
Reputation: 2434
Check out the fantastically awesome gh-pages npm module. With a few lines of code, eg:
var ghpages = require('gh-pages');
var path = require('path');
ghpages.publish(path.join(__dirname, 'dist'), function(err) { ... });
You will be create the gh-pages branch, and push it to github!
In more detail, from the docs:
Calling this function will create a temporary clone of the current repository, create a
gh-pages
branch if one doesn't already exist, copy over all files from the base path, or only those that match patterns from the optionalsrc
configuration, commit all changes, and push to theorigin
remote.
It is super configurable, and works like a charm for me.
Upvotes: 1
Reputation: 1
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
Upvotes: 1
Reputation: 388023
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.
Upvotes: 11