Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我如何将我的git回购的一部分推给Heroku?_Git_Heroku - Fatal编程技术网

我如何将我的git回购的一部分推给Heroku?

我如何将我的git回购的一部分推给Heroku?,git,heroku,Git,Heroku,我有一个已经在Github上的多模块应用程序。它由两个模块组成,一个是Android应用程序,另一个是基于Rails的Web应用程序。因此,我的项目的目录结构是: ProjectRoot | +-- web | +-- android | +-- .git 因此,我不能简单地将cd放入ProjectRoot并将我的应用程序推送到Heroku,因为Rails应用程序的根文件夹是ProjectRoot/web。有没有办法将web文件夹推送到Heroku?如果我将web转换为git子模块,应该很容易

我有一个已经在Github上的多模块应用程序。它由两个模块组成,一个是Android应用程序,另一个是基于Rails的Web应用程序。因此,我的项目的目录结构是:

ProjectRoot
|
+-- web
|
+-- android
|
+-- .git

因此,我不能简单地将
cd
放入ProjectRoot并将我的应用程序推送到Heroku,因为Rails应用程序的根文件夹是
ProjectRoot/web
。有没有办法将
web
文件夹推送到Heroku?如果我将web转换为git子模块,应该很容易实现这一点,但我在git上只有5个私有repo,我更喜欢在我的整个应用程序中只使用1个repo。

您可以使用
git子树推送
。它将生成一个以您的目录为根目录的新提交树,并推送它

git subtree push --prefix web heroku master

完整的文档是。

您也可以使用git分支而不是子文件夹。如果您有git 1.7.2或更高版本,只需执行
git checkout--Orphant android
即可创建一个与主分支断开连接的分支(此处假定为web文件夹)。签出孤立分支后,运行
git rm-rf.
删除现有文件,然后将android特定文件复制到现在为空的根目录

如果要为每个模块使用单独的文件夹,可以克隆存储库两次并使用以下结构:

ProjectRoot
├── android
│   └── .git
└── web
    └── .git

git子树
命令(现在内置)是一种很好的方法。如果要将分支的子树推送到主节点,可以使用以下方法:

git push--force heroku`git子树拆分--前缀web头`:master

这非常有效。如果您想结合子树推送特定的标记或分支,该怎么办?像“git push heroku yourbranch:master”一样,在这种情况下,您不能使用
子树push
快捷方式,必须自己链接命令。例如:
git-push-heroku`git-subtree-split--prefix-web-yourbrance`:master
FYI,
git-subtree
现在是核心git的一部分(无需安装任何东西,只要您的git版本是最新的)可能的副本