I have a folder in my master branch named public/, what would be the easiest way to copy its contents to the root directory in a different branch, such as gh-pages?
I have a folder in my master branch named public/ , what would be
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One really nice trick illustrated in Generate GitHub pages in a submodule by
Blind Gaenger (Bernd Jünger) is to declare a branch as a submodule for another branch!
So if your
publiccontent was in its own orphan branch (likegh-pagescontent is usually kept in its own orphan branch), then you could:publicas a submodule of your main repo inmasterbranchgh-pagesSo any modification that you make in submodule
publicwhen you are inmasterbranch can be updated (git submodule update) once you switch togh-pagesbranch!I am not saying this is a solution for your current setup, because it involves removing
publicfrom your main content, and adding it back in its own branch (ie, the other solutions might be more straightforward), but it is an interesting way to share a common directory:But once you have created an orphan branch to include that (
public) content, the trick to add that branch content as a submodule for other branch is:And you can repeat that step for your
gh-pagesbranch.That will create a directory "
public", present both when you checkoutmasterorgh-pages.In both cases (both checkout), a
git submodule updatewill be enough to get back the latest evolutions done onpublicsubmodule.And as usual when it comes to submodules, once you do modifications in
publicdirectory, make sure you are on its ‘public‘ branch, commit and push, then go back one directory above, and add-commit again.Update August 2016: Simpler GitHub Pages publishing now allows to keep your page files in a subfolder of the same branch (no more
gh-pagesneeded):So the submodule trick is no longer necessary to make both type of content visible through the same branch.