I've just cloned a repo I have hosted on Github but this only checked out the master
branch. There's also a gh-pages
branch that Github creates automatically to host the project's site.
I want to also clone (checkout? pull?) this branch to work on it and I've found a lot of material on this that got me a bit confused.
This answer says that I should do:
git checkout -b gh-pages origin/gh-pages
and this one implies the command could be:
git branch -f gh-pages upstream/gh-pages
What is the difference between these two? Should I stick with the first one?
Add. If I do git branch -a
I get:
remotes/origin/HEAD -> origin/master
remotes/origin/gh-pages
remotes/origin/master
gh-pages
if that branch doesn't exist. gh-pages
branch to upstream/gh-page
. Personally, I prefer declaring gh-pages
branch as a submodule .
That allows you to work on master, while seeing/updating the gh-pages
content in a gh-pages
subfolder (declared as a submodule).
Update August 2016: Simpler GitHub Pages publishing now allows to keep your page files in a subfolder of the same branch (no more gh-pages
needed):
So you don't even have to checkout another branch now (uf the upstream repo chose the new content organization)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.