Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:26:38+00:00 2026-06-10T00:26:38+00:00

I have a folder in my master branch named public/ , what would be

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:26:40+00:00Added an answer on June 10, 2026 at 12:26 am

    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 public content was in its own orphan branch (like gh-pages content is usually kept in its own orphan branch), then you could:

    • declare public as a submodule of your main repo in master branch
    • declare the same public as a submodule of your main repo in gh-pages

    So any modification that you make in submodule public when you are in master branch can be updated (git submodule update) once you switch to gh-pages branch!

    I am not saying this is a solution for your current setup, because it involves removing public from 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:

    cd yourRepo
    git symbolic-ref HEAD refs/heads/public
    rm .git/index
    mv public ..
    git clean -fdx
    mv ../public/* .
    git add .
    git commit -m "public content in orphan branch public"
    git push origin public
    

    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:

    $ git checkout master
    $ git submodule add -b public git@github.com:user/repo.git public
    $ git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #    new file:   .gitmodules
    #    new file:   public
    #
    $ git commit -m "added public as submodule"
    $ git push
    

    And you can repeat that step for your gh-pages branch.

    That will create a directory "public", present both when you checkout master or gh-pages.
    In both cases (both checkout), a git submodule update will be enough to get back the latest evolutions done on public submodule.
    And as usual when it comes to submodules, once you do modifications in public directory, 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-pages needed):

    Now you can select a source in your repository settings and GitHub Pages will look for your content there.

    So the submodule trick is no longer necessary to make both type of content visible through the same branch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way, with the Eclipse IDE, to have a master folder containing
I have folder structure and I would like to create JSON objects based on
I have a folder with some dotfiles I would like to make symlinks for.
I have a folder named img and i want to use js to look
We have currently just master branch. Our current workflow involves implementing the features locally,
Is there a way to update a side branch with information from another (master
I have a repo that I have a master branch which will end up
I have a folder that is my working copy. How do I remove all
I have e.g. two branches. master and development. I created a branch called master_fix.
I have folder home/admin. In this folder there is index.php. When i access to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.