I\'m developing a jQuery plugin that\'s being hosting on GitHub. It has a demo included of which I\'m manually copying and pushing to the branch gh-pages
, what
commit and push to master..
then :
git checkout gh-pages // -> go to gh-pages branch
git rebase master // bring gh-pages up to date with master
git push origin gh-pages // commit the changes
git checkout master // return to the master branch
Do not do what denbuzze suggests above!! The + (plus sign) in the push makes it quietly accept non-fastforward updates. I found out the hard way that this can irrevocably cause work to be lost by leading to dangling commits. Simply removing the plus signs makes this a safer approach.
push = refs/heads/master:refs/heads/gh-pages
push = refs/heads/master:refs/heads/master
now instead of causing a force update this will cause a warning & pull suggestion
To https://github.com/someuser/repo.git
! [rejected] master -> gh-pages (fetch first)
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/someuser/repo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
OR you can just use the cmd below, this will push your local master branch to gh-pages master branch.
git push -f origin master:gh-pages
Add the following 2 lines to the [remote "origin"]
section of .git/config
:
push = +refs/heads/master:refs/heads/gh-pages
push = +refs/heads/master:refs/heads/master
Every time you push
it will automatically push master to gh-pages as well.
I'm using this for the jQuery Lifestream project.
git checkout gh-pages
git merge master
git push origin gh-pages
I personally like to wrap this in an alias:
alias gpogh="git checkout gh-pages && git merge master && git push origin gh-pages && git checkout -"
This mirrors your master to gh-pages
, pushes to github, then switches back the previous branch you were working on.