如何将我的 git repo 的一部分推送到 Heroku?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5977234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I push a part of my git repo to Heroku?
提问by Behrang Saeedzadeh
I have a multi-module app that is already on Github. It is comprised of two modules, one of them an Android app and the other a Rails based Web app. So my project's directory structure is in the form of:
我有一个已经在 Github 上的多模块应用程序。它由两个模块组成,一个是 Android 应用程序,另一个是基于 Rails 的 Web 应用程序。所以我的项目的目录结构是这样的形式:
ProjectRoot
|
+-- web
|
+-- android
|
+-- .git
As such I cannot simply cd
into ProjectRoot and push my app to Heroku as the root folder of the Rails app is ProjectRoot/web
. Is there a way to push the web
folder to Heroku? If I turn web into a git sub module, it should be easy to accomplish this, but then I only have 5 private repos on Git and I prefer to consume only 1 repo for my whole app.
因此,我不能简单地cd
进入 ProjectRoot 并将我的应用程序推送到 Heroku,因为 Rails 应用程序的根文件夹是ProjectRoot/web
. 有没有办法将web
文件夹推送到 Heroku?如果我将 web 变成一个 git 子模块,应该很容易实现这一点,但是我在 Git 上只有 5 个私有存储库,而且我更愿意为我的整个应用程序只使用 1 个存储库。
回答by Micha?l Witrant
回答by brookr
The git subtree
command (built in, now) is a good way to do this. If you want to push a subtree of a branch to become your master, you can use something like:
该git subtree
命令(在建,现在)是一个很好的办法做到这一点。如果你想推动一个分支的子树成为你的主人,你可以使用类似的东西:
git push --force heroku `git subtree split --prefix web HEAD`:master
git push --force heroku `git subtree split --prefix web HEAD`:master
回答by bmaland
You could also use git branches instead of subfolders. If you have git 1.7.2 or newer, you can simply do git checkout --orphan android
to create a branch that is disconnected from your master branch (assumed here to be the web folder). Once you have checked out the orphan branch, run git rm -rf .
to remove existing files before copying in your android-specific files to the now empty root directory.
您还可以使用 git 分支而不是子文件夹。如果您有 git 1.7.2 或更新版本,您可以简单git checkout --orphan android
地创建一个与主分支断开连接的分支(这里假设为 web 文件夹)。检出孤立分支后,运行git rm -rf .
以删除现有文件,然后再将您的 android 特定文件复制到现在为空的根目录。
If you want to use separate folders for each module, you can clone the repository twice and use this structure:
如果您想为每个模块使用单独的文件夹,您可以克隆存储库两次并使用以下结构:
ProjectRoot
├── android
│?? └── .git
└── web
└── .git