Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

github how to include files from master in new git branch gh-pages

Tags:

git

github

github has this feature where you can publish "Project Pages" if you create a new branch gh-pages in your project. For full description see http://pages.github.com/

My project is just html/images, so I just want to serve the master branch.

so how do I create a new branch called gh-pages that is just exact copy of master? some kind of link operation?

Thanks

like image 318
git Avatar asked Nov 10 '09 02:11

git


People also ask

How do I merge master branch to GH-pages?

If thats the case, the safest option is to merge your master branch into the gh-pages branch (assuming you dont have other files on master you would rather not have on the gh-pages branch). The command suggested git push -f origin master:gh-pages will push your local master branch to the gh-pages branch.

How do I change my master page to GH?

follow the steps below to setup your projects folders on your local system. Open Terminal. app, create project parent folder ("grandmaster"), and a subfolder for the "master" branch. Initialise a new git repository for the project and push the "master" branch to GitHub.

How do I add a file to my GitHub branch?

In the command line, go to the root directory where your local files are. Optionally initialize the local directory (git init). Add the your file changes (git add) and commit your changes (git commit). Finally, push your changes of the local file or repository to GitHub (git push).


2 Answers

You want branch 'gh-pages' in your GitHub repository to be the same as 'master' branch. The simplest solution would be to configure git to push branch 'master' to 'gh-pages' automatically.

Assuming that your GitHub repository you push into is configured as 'origin' remote, you can somply do:

$ git config --add remote.origin.push +refs/heads/master:refs/heads/gh-pages

Or if you prefer you can simply edit .git/config file directly.

Then when you do git push or git push origin you would push 'master' branch in your repository into 'gh-pages' branch into repository on GitHub.

See git-push manpage for documentation and description of refspec format.

like image 140
Jakub Narębski Avatar answered Oct 07 '22 08:10

Jakub Narębski


That's actually the default behavior of the git branch command. The more complicated symbolic-ref and clean commands you see listed in the "pages" writeup are needed to avoid doing exactly this.

So, at your project root, on the master branch:

git branch gh-pages
git checkout gh-pages

Or just:

git checkout -b gh-pages
like image 35
Ash Wilson Avatar answered Oct 07 '22 08:10

Ash Wilson