如何在开发Git仓库中保留Heroku的部署仓库并保持它们的独立性? [英] How to keep a deployment repo for Heroku within a development Git repo and keep them separate?

查看:126
本文介绍了如何在开发Git仓库中保留Heroku的部署仓库并保持它们的独立性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git repo,用于开发我的应用程序,现在我想部署到Heroku。不过,我不想部署这个回购本身,而是在这个回购中的代码构建。我的构建系统在我的repo目录中创建了一个 dist 目录,其中包含了在任何地方进行部署所需的一切。它被设置为在.gitignore中被忽略,因为它不需要存储它,因为它可以在任何时候重建,并且是多余的。然而,Heroku需要一个git仓库进行部署。我可以手动将 dist 中的输出复制到其他一些存储库中,但是这看起来确实很难看。我希望能够开发源代码,构建部署代码,并将前者推送到GitHub / Lab,后者则不会重叠。

我想要什么是这样的:我的 dist 文件夹是它自己的git repo,以满足Heroku,这不包括在父dev的历史记录中,即当我推动我的dev回购到GitHub或GitLab, dist 文件夹将被忽略。当我向Heroku推送 dist 的内容时,它不知道它包含在开发项目中。这样,我的构建过程会自动更改我的部署回购,我可以在必要时进行提交以进行部署事件标记。



我不清楚如何设置如果可能的话,这一点。我听说过有关子模块的可怕事情,我甚至不知道这是适合这项工作的正确工具,因为它似乎更多地涉及到我的其他外部回购。在这里,我想创建一个只存在于我的家长回购协议中的回购。



如果有其他人知道比我要求的更好的东西,我愿意接受我的想法。

解决方案

我会创建另一个名为'dist'的分支:

  git checkout -b'dist'



然后,我会改变gitignore文件,以便包含'dist'文件夹。

然后我会把dist分支推到heroku上:

  git push heroku dist:master 

这是否适合您?

I have a git repo that I've used to develop out my app and now I want to deploy to Heroku. However I don't want to deploy this repo itself but rather a build of the code in this repo. My build system creates a dist directory within my repo directory that contains everything necessary for deployment anywhere. It is set up to be ignored in .gitignore because it's not necessary to store it as it can be rebuilt any time and would be redundant. However, Heroku needs a git repo for deployment. I could manually copy the output in dist to some other repo I keep around just for Heroku but that seems really ugly. I want to be able to develop source, build deployment code, and the push the former to GitHub/Lab and the latter to Heroku without overlap.

What I'd like is something like this: My dist folder is its own git repo, to satisfy Heroku, that isn't included in the parent dev repo's history, i.e. when I push my dev repo to GitHub or GitLab, the dist folder is ignored. When I push the contents of dist to Heroku, it has no knowledge of the fact that it's contained within a development project. This way my build process automatically changes my deployment repo, which I can make commits to when necessary to mark deployment events.

What I'm not sure about is how to set this up, if it's possible. I've heard horrible things about submodules and I'm not even sure that's the right tool for the job, as it seems to relate more to including other outside repos within mine. Here I want to create a repo that live only within my parent repo.

If there are others with a similar setup that know of something better than what I've asked for, I'm open to ideas.

解决方案

I would create another branch called 'dist':

git checkout -b 'dist'

And inside that branch I would alter the gitignore file so that the 'dist' folder is included.

I'd then push my dist branch to heroku like so:

git push heroku dist:master

Does that work for you?

这篇关于如何在开发Git仓库中保留Heroku的部署仓库并保持它们的独立性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆