复制另一个分支上的目录内容
我在 github 上有 2 个分支:
master
gh-pages
我的分支 master
具有目录 _site
,其中包含所有我需要存储在 gh-pages 根目录下的文件。
我正在使用 git 命令: git checkout master -- _site
将_site
的内容复制到gh-pages
分支。
我的问题是,我正在获取目录及其内容,而我只需要根目录上的内容。
这可能吗?
I have 2 branches on github:
master
gh-pages
My branch master
has the directory _site
which contains all the files that I need to be stored on the root of gh-pages
.
I am using the git command:git checkout master -- _site
To copy the contents of _site
to the gh-pages
branch.
My issue is that I am getting the directory and it's content while I need the content only on the root.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种选择是将 gh-pages 设置为您自己的存储库的子模块。
这意味着将
gh-pages
分支内容添加为当前存储库的子文件夹,位于master
分支中,使用git 子模块
。(除非,如此处所述,您选择
master
分支本身作为 GitHub Pages 的源)您将有一个
gh-pages
子文件夹,您可以随时更新该子文件夹:您将从主存储库生成网站内容,而不是在目录
_site
中,而是在目录gh-pages
中(因此将直接拥有网站内容)。One option is to set gh-pages as submodule of your own repository.
That means adding the
gh-pages
branch content as a subfolder of your current repository, in themaster
branch, usinggit submodule
.(unless, as explained here, you chose the
master
branch itself as source for GitHub Pages)You will have a
gh-pages
subfolder, that you can update at any time with:You would generate, from your main repository, the site content not in the directory
_site
, but in the directorygh-pages
(which would thereforce have directly the site content).