简体   繁体   English

如何将主分支文件夹添加到github页面?

[英]How to add master branch folder to github pages?

Hello I have a github repository where I am writing some code and making a folder which contains some HTML. 您好,我有一个github存储库,我在其中编写一些代码并制作一个包含HTML的文件夹。

I have created a github page for my repo using github pages and which loads data from my README.md 我已经使用github页面为我的仓库创建了一个github页面,并且从README.md加载数据

So now I have 2 branches: 所以现在我有2个分支:

master gh-pages master gh-pages

My master branch has the following structure: 我的master分支具有以下结构:

HTML/
IMAGES/
codeFiles.py
codeFile2.py
...

Is there any ways I can include just my HTML/ folder from my master branch into my gh-pages branch. 有什么方法可以将我的master分支中的HTML/文件夹仅包含到gh-pages分支中。

What I am looking for is a structure like of my gh-pages 我正在寻找的是类似gh-pages的结构

Images/
Javascripts/
Styles/
HTML/
index.html
...

Note I don't use gh-pages myself, so I haven't tried this exact scenario. 请注意,我本人不使用gh-pages,因此我没有尝试过这种确切的情况。 If you do this I strongly advise doing it in a new clone of the repository and checking both branches thoroughly before pushing any changes. 如果您这样做,我强烈建议您在存储库的新克隆中进行此操作,并在推送任何更改之前彻底检查两个分支。

You could do: 您可以这样做:

git checkout gh-pages
git read-tree master:HTML
git clean -df
git checkout .
git commit

All previous contents of the gh-pages branch would be removed in the new commit, replaced by the contents of the HTML directory from the current version of your master branch. gh-pages分支的所有先前内容将在新提交中删除,由master分支的当前版本中的HTML目录的内容替换。 This would not cause future changes to that content to be synced between those branches, but you could use the subtree merge strategy to merge changes to that shared content from the other branch: 这不会导致对该内容的将来更改在那些分支之间进行同步,但是您可以使用子树合并策略来合并对来自另一个分支的该共享内容的更改:

git merge -s subtree $other_branch

But this isn't likely to work as well as merges typically do in git because those branches still don't share any history, only some of the content. 但这并不能像git中的合并那样好用,因为那些分支仍然不共享任何历史,仅共享部分内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将master合并到github中的Windows分支中? - how to merge master into branch in github for windows? 如何使用 Git 命令将多个单独的文件夹添加到 GitHub,以便每个文件夹可以单独更新 - How to use Git commands to add multiple separate folders to GitHub such that each folder can be updated seperately 如何重置整个Git存储库,而不只是重置“ Master”分支,以匹配Remote? - How to reset the entire Git repository, and not only the “Master” branch, to match Remote? Git:如何更新master分支,一步切换到master分支? - Git: How to update the master branch and switch to it in one step? 如何将更改从master转移到Feature分支 - How can I get changes from master into feature branch GIT:如何使用 git 命令获取从主分支到自定义分支的最新更改? - GIT : How to get latest changes from master branch to the custom branch using git commands? 如何在 Windows 上可视化 GitHub 分支历史记录? - How can I visualize GitHub branch history on Windows? 如何从git导出所有分支更改的文件与本地主文件相比 - how to export all branch changed files compared to local master from git pdf中如何根据奇数页和偶数页添加空白页 - How to add blank pages in pdf based on odd and even pages Github CLI Beta:如何查看文件夹内的自述文件 - Github CLI Beta: How to view readme inside a folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM