#Lets get this party started...
-
Star
(282)
You must be signed in to star a gist -
Fork
(45)
You must be signed in to fork a gist
-
-
Save chrisjacob/833223 to your computer and use it in GitHub Desktop.
So basically all you're doing is creating two separate working copies on different branches? In no way are the working copies linked, aside from having the same remote?
I stumbled on this and at first had no idea why you would want to do this, then you mentioned it being useful for output from static site generators. With this I can probably use a single repo instead of two repos (one for the documentation's source which uses Sphinx, the other for gh-pages). Thanks!
BTW, the webpage 404s: http://chrisjacob.github.com/grandmaster/
Has anyone tried to replicate this with git submodules?
@sprugman See Section 5 in http://rafeca.com/2012/01/17/automate-your-release-flow/ for hints.
I have written a small script that assists in synchronizing a subdirectory with the gh-pages branch. It's in my scriptlets repo. Use ghpsd init for creating an empty gh-pages subdirectory that will hold the contents of your gh-pages branch. After adding to this subdirectory, use ghpsd merge for updating the gh-pages branch. Note that you still have to push to GitHub.
It works by cloning a copy of the repo into a shadow subdirectory named .gh-pages (which is added to .gitignore, too); this makes updating the gh-pages branch work seamless. Call ghpsd checkout to recreate the hidden .gh-pages folder, this clones locally and does not require network access.
Hi! Very nice tutorial. I have a question: how can I create the two repositories via Github web interface and then do what your tutorial says (I don't want to use automatic page generator)?
Thanks in advance!
use symbolic link for _site to gh-pages, and when you build the site ,it will auto-update the gh-pages.
alias blog0='~/.gem/ruby/2.1.0/bin/jekyll build'
alias blog99='git add . && git commit -a -m "update site" && git push'
alias blog.username='blog0 && cd .. && cd gh-pages && blog99 && cd .. && cd master'
I'm very new at this, and your instructions didn't at first work for me. When I tried to push, I got an error message: Permission denied (publickey). A web search led to me setting up the necessary keys for the SSH stuff to be in place. And then your instructions worked until this line:
ichris:gh-pages $ git checkout origin/gh-pages -b gh-pages
When I tried that, I got an error message:
fatal: not a git repository (or any of the parent directories): .git
Any ideas what I may have missed??
@rafaelespericueta I had the same issues!
Instead of running git remote add origin [email protected]:username/grandmaster.git I had to run git remote set-url origin [email protected]:username/grandmaster.git.
When trying to checkout gh-pages, I found that in the previous step to clone the repo, it had cloned the whole repo under gh-pages - creating the folder structure:
/grandmaster/gh-pages/grandmaster/
Manually moving all the files and folders (including the .git folder) up the tree one level (into gh-pages) and deleting the now empty extraneous "grandmaster" folder got everything back on track.
Further to my post above - at the clone step, use:
git clone -b gh-pages --single-branch [email protected]:username/grandmaster.git .
Note the "." at the end!
This will clone only the gh-pages branch (no need to do the delete master branch step) and also place it correctly without creating a further project folder.
With git 2.5, you don't need two clones. Just use git worktree add -b gh-pages ../gh-pages origin/gh-pages as described at https://github.com/blog/2042-git-2-5-including-multiple-worktrees-and-triangular-workflows.
how to make an existing project to become just like in this format? I have an existing project in github and would like to have a local storage formatted like this but this guide seems to help build the format from zero. What steps should I do to make it?
how to make something like this for an existing repository?
i got this error
fatal: Cannot update paths and switch to branch 'gh-pages' at the same time.
Did you intend to checkout 'version-control/grandmaster/gh-pages/origin/gh-pages' which can not be resolved as commit?
when try to
git checkout origin/gh-pages -b gh-pages
hmm, well i somehow able to achieve the same result with different commands
The essence of this gist answers the question "how do I alter two branches without having to checkout constantly between them?"
For an existing repo you can actually skip most of the instructions in this gist since most of them are a sort of complicated way of creating the repo as you go.
So if you already have a repo on github, follow these instructions to create the branch locally and push it back to github: https://help.github.com/articles/creating-project-pages-manually/
Once you have the branch made, clone the repo locally into a sibling folder with a different name. In this sibling folder checkout the gh-pages repo, then delete the master branch. This way you can push to master from one folder and push to gh-pages from the other but you can see the files side by side.
I really like this approach. Thanks for the tip.
Thanks for the post. It works for my pages
git push --force origin $(git commit-tree -m "auto" master:dist):gh-pages
tree="$(cp .git/index{,-bk} && git add -f dist && git write-tree --prefix=dist && mv .git/index{-bk,})"
git push -f origin "$(git commit-tree -m auto "$tree")":gh-pages
tree="$(export GIT_INDEX_FILE="$(mktemp)"; cat .git/index >"$GIT_INDEX_FILE"; git add -f dist && git write-tree --prefix=dist)"
after that, imo you should do something like
git update-ref refs/heads/gh-pages "$(git commit-tree -p gh-pages -m auto "$tree")"
still trying to figure it out with a build folder that is in gitignore but would be root level on gh-pages deploy
I think you can cut some few steps off. If you don't clone the repo, you won't have the master branch hanging around the gh-pages. Nice tho 👍
also you can use git worktree
for an existing project inside your workdir
$ git worktree add ../gh-pages gh-pages@hendrawd I got the same error message. How did you solve it?
You could easily use a hook to synchronize pushing, if anyone is still wondering how to approach that
This example is dead
It sure is dead. It should be removed.
Why is it dead?
A post-commit hook is a much clearer approach. Refer to https://githooks.com/.
Example is dead because Github made things much easier I believe. Example if from 2013...
Once the branch is pushed to GitHub, you have to go to the Settings page of the repository. In the section “GitHub Pages”, select gh-pages as the source. The step is described in more details here. If successful, you will see a message saying “Your site is published at https://your-username.github.io/your-repository/”.
Hey, very nice tutorial.
Since i'm new to GitHub, I was using their tutorial https://help.github.com/articles/fork-a-repo to create a fork. However, I prefer your approach since I like to keep things organised. But I'm not sure if I got it right. At Github article they show us how to keep your fork updated with the original one, doing this:
But that is only for the 'master' branch, right? Using your approach, how can I have both master and gh-pages in sync with the original repo?
Thanks.