是否可以将 git 存储库推送到另一个存储库的文件夹(例如,git 中心页面)?

is it possible to push a git repository to a folder of another repo (for example, github pages)?

我有一个 git 存储库 - 让我们称之为 A,在 github 上有一个远程。我有另一个回购 - B.

是否可以设置一种方法将 A 推入 B 中的子文件夹?

比如我有一个用html/js/css写的项目。我想将这个项目放在一个独立的 github 仓库中,并在我的 github 页面仓库中的一个子目录中托管(例如,作为 broshen.github.io/project/index.html)

我该如何设置?

将项目 A 添加为项目 B 的子模块。

# go into project 'B'
$ git submodule add <repo-A-url>
$ git submodule init              # intitialize the submodule
$ git submodule update            # update all the changes/commits of submodule

More Submodule

您可以将 A 添加为存储库 B 中的子模块,但您需要在任何时候要部署更改时提交 B 中的子模块更新。

既然你提到了broshen.github.io/project/index.html,似乎值得一提的是你可以添加一个gh-pages分支(或配置它使用docs/)来自动部署到username.github.io/reponame/ (例如 https://dahlbyk.github.io/posh-git/ deployed from gh-pages)。