Git branch: gh-pages

I have a repo on github. I recently discovered GitHub pages and I want to use them.
I would like to create this new branch, and then, when I need to, either commit to the master branch or the gh-pages branch.

How can i do this? Do I need to create another folder inside my repo?

+45
git git-branch github-pages
Jan 20 2018-11-18T00:
source share
8 answers

You may find this tutorial useful:

Configuring GitHub Pages "gh-pages" branch branch and "master" as subfolders of the parent folder of the project ("grandmaster") .

For me, this approach seems simpler than using git checkout gh-pages every time you want to edit the contents of gh pages. Let me know what you think ^ _ ^

Edit: I updated the tutorial link - thanks @Cawas. Old tuotial (not recommended) was https://gist.github.com/825950

+24
Feb 14 2018-11-11T00:
source share

In later versions of git, there is an alternative to the git symbolic-ref method, which Chandra explained. This avoids the need to use lower level commands.

 git checkout --orphan gh-pages git rm -rf . 
+32
Jan 23 2018-11-11T00:
source share

In your local clone,

 git symbolic-ref HEAD refs/heads/gh-pages rm .git/index git clean -fdx 

Then git checkout gh-pages and write your pages. git push origin gh-pages when you are ready to publish pages.

+7
Jan 20 '11 at 17:41
source share

Manual creation of project pages

Adding a new set of pages for a project manually is easy if you are used to using the git command line.

https://help.github.com/articles/creating-project-pages-manually

+1
Feb 27 '13 at 16:28
source share

There is another solution to your problem: Forget about gh-pages and branching; Put your static files that are supposed to be serviced inside the /docs directory, then go to your project settings and tell github to serve the /docs content.

For more information see this

+1
Jul 20 '17 at 16:24
source share

Publish a static site as follows:

 git subtree push --prefix www origin gh-pages 

Where www is the doc root directory where your static files are located. Your static site is now available: https://[user_name].imtqy.com/[repo_name]/

+1
Oct 28 '17 at 20:47 on
source share

A typical way is branch transition: git checkout master if you want to work with a master and git checkout gh-pages if you want to work with gh-pages .

Starting with git 2.5, you can check both branches at the same time (in different directories). See https://github.com/blog/2042-git-2-5-including-multiple-worktrees-and-triangular-workflows . Setup via git worktree add -b gh-pages ../gh-pages origin/gh-pages .

Bonus: if the contents of the subdirectory of your master tag is the contents of gh-pages , use the script provided at https://github.com/X1011/git-directory-deploy .

0
Nov 23 '15 at 1:36
source share

Are your gh pages and main branch EXACTLY the same folder structure? If so, why do you want to have two branches? just maintain one gh-pages branch! but if for some reason you want to have both branches that are constantly in sync, it is best to use git rebase . See here:
http://lea.verou.me/2011/10/easily-keep-gh-pages-in-sync-with-master/

You can also cherry-pick only the files you need from the wizard and click them on the gh pages using the special git checkout use case. See here:
http://oli.jp/2011/github-pages-workflow/#gh-pages-workflow
http://nicolasgallagher.com/git-checkout-specific-files-from-another-branch/

To deal with the same problem, I came to the conclusion that gh pages will usually have a different code base than master. In other words, gh pages should only include the contents of the dist / build / publish folder of your project, while the wizard will include your configuration files, uninstalled scripts and styles, etc.

My suggestion was to create gh pages as a --orphan branch and include only material ready for publication in it. You should clone from your host in another local directory, use git checkout --orphan gh-pages to create gh pages, and then delete all unnecessary files with git rm -rf . . From there, you can continue and click on the gh pages after adding your publication-only files. See Github docs for more details:
https://help.github.com/articles/creating-project-pages-manually/

Good luck.

-one
Nov 11 '15 at 22:51
source share



All Articles