简体   繁体   中英

Reference directory from master branch on gh-pages branch

I followed the GitHub instructions to create a gh-pages branch for a javascript library. The library's build script uses JsDocs to create a docs directory - I would like my GitHub page to be able to reference those documents.

I have been manually copying the docs directory from master to gh-pages , but I think a better solution would be to either:

  • Set up my gh-pages branch to reference the docs directory on master , or
  • Create some type of hook that copies only the docs directory to gh-pages whenever someone commits to master

How can I provide this documentation to users with minimal effort and lessen the chance of falling out of sync?

The following will save you from having to checkout the other branch to get at those files:

you can get another branches version of a directory with

git checkout master -- path/to/my/docs/dir

you can list files in a directory in another branch with

git ls-files $(git rev-parse master) -- path/to/my/docs/dir

you can stream a specific file from another branch with

git show master:path/to/my/docs/dir/somefile.txt

Hope this is enough to get you to the next step.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM