Display GitHub README screenshot stored in a different branch, both on GitHub and locally

ⅰ亾dé卋堺 提交于 2019-12-02 08:19:58

No, this is not possible and you shouldn't expect it to.

You should make the assets folder a part of your main branch, or you should separate the two into different repositories, or something along those lines.

There is a good reason why GitHub serves this screenshot but that "good reason" is just a technical reason related to how GitHub serves content from your repository.

Let's look at the URL to your screenshot, as used in the served HTML from your main repository page:

https://raw.githubusercontent.com/devliber/ReadmeScreenshotBranch/assets/screenshot.png

As you can see, the name of the branch with the image is part of the URL. Let's try to hack the URL back to your README:

https://raw.githubusercontent.com/devliber/ReadmeScreenshotBranch/master/README.md

If you try this URL you will see that it shows your README file.

So the issue here is that your "hack" to get to the screenshot, from another branch, is that you get this URL:

https://raw.githubusercontent.com/devliber/ReadmeScreenshotBranch/master/../assets/screenshot.png

This resolves to the exact same URL as the first one i posted here and that is why you see the image.

However, if you check out branch X then you shouldn't expect any content from branch Y to be present in your working folder. It "works" on GitHub because of the way they serve content from your branches but it won't, and shouldn't work locally, except if you start checking out multiple branches using worktrees.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!