Skip to content

Git copy master to gh pages

Henryk Paluch edited this page May 22, 2016 · 1 revision

Git - copy master to GH Pages

Quite often you need to just copy content of your master branch to gh-pages, for example my Project https://github.com/hpaluch/html5 is on master branch, but I want to verbatim copy it to gh-pages branch to be available as Live demo on https://hpaluch.github.io/html5/knob_canvas/.

Solution - create simple script called copy-to-gh-pages.sh with this content:

#!/bin/bash

# note set -e is to exit on error
set -ex

git checkout gh-pages
git merge -s recursive -X theirs master
git checkout master
git branch

And run it in your project directory.

Always verify that you are again in correct branch (master in this example) using command:

git branch

  gh-pages
* master

Current branch is marked with asterisk (*).

To get graph of your commits, you can use this command:

git log --graph --all --decorate --oneline

* 3ba1b77 (HEAD, origin/master, origin/gh-pages, master, gh-pages) Angle propert
* 07987b2 Subproject README
* 28a541b Live demo link
* 21857a8 First non-interactive version
Clone this wiki locally