Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
This is the process
given
to create a branch for GitHub Project Pages:
cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" > index.html
git add .
git commit -a -m "First pages commit"
git push origin gh-pages
It states that git symbolic-ref HEAD refs/heads/gh-pages
will create a new root branch. I'm wondering what the difference between a root branch and a regular branch is.
A "root branch" is one without a previous history. *
If you are at master and you do git branch gh-pages
, gh-pages will be basedd off master.
Here, the intention is to create a branch for github pages, which is typically not associated with the history of your repo (master and other branches) and hence the usage of git symbolic-ref
Also see here: https://stackoverflow.com/a/8815361/526535
*
It is also called an orphan branch and git checkout --orphan
will now do the same thing as the git symbolic-ref
that was being done before
Also see my answer here: https://stackoverflow.com/a/5690048/526535
–
The Git 223 (Q3 2019)+ version of that operation would be using git switch
:
git switch --orphan gh-pages
What would be the problems if gh-pages
branch is based off of master
? would it change anything?
Then you would find all tracked files from master
in gh-pages
: you would have to remove them first before using your new branch
git switch -c gh-pagres master
git rm -r .
git commit -m "empty new branch"
Note that since Sept. 2020, repositories that use GitHub Pages can now build and deploy from any branch.
And since Aug. 2022, GitHub Pages uses Actions by default, using a starter workflow.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.