如何将不同的本地Git分支推送到Heroku / master [英] How to push different local Git branches to Heroku/master

查看:254
本文介绍了如何将不同的本地Git分支推送到Heroku / master的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Heroku的策略是忽略所有分支,但忽略主人。

虽然我确信Heroku的设计师对此策略有很好的理由(我猜的是存储和性能优化),我作为开发人员的后果是,无论我可能在做什么本地主题分支,我都想要一个简单的方法将Heroku的主人切换到本地主题分支,并执行git push heroku -f以覆盖Heroku上的master。



通过阅读 http://progit.org/book/ch9-5.html

 git push -f heroku local-topic-branch:refs / heads / master 

我真的很喜欢在配置中设置它的方法文件,以便git push heroku始终执行上述操作,用任何当前分支所在的名称替换 local-topic-branch 。如果有人知道如何做到这一点,请让我知道!



当然,需要注意的是,如果我是唯一一个能够推送到该Heroku应用程序/存储库。测试或QA团队可能会管理这样一个存储库来尝试不同的候选分支机构,但他们必须进行协调,以便他们都能同意他们在任何特定日期向其推送的分支。

不用说,拥有一个单独的远程存储库(如GitHub)也是一个非常好的主意,没有这个限制来支持所有的事情。我会把这个叫做origin,并使用heroku作为Heroku,这样git push总是将所有东西都备份起来,并且git push heroku将我目前所在的任何分支推送到Heroku的主分支上,如果有必要的话。



这个工作吗?

 
[remoteheroku]
url = git@heroku.com:my-app.git
push = + refs / heads / *:refs / heads / master

在开始试验之前,我想听听更有经验的人,不过我想我可以在Heroku上创建一个虚拟应用程序并进行实验。



至于抓取,我并不在乎Heroku存储库是否是只写的。我还有一个单独的存储库,比如GitHub,用于备份和克隆我所有的工作。



脚注:这个问题与类似,但不完全相同> 使用Heroku的分支策略进行良好的Git部署?

解决方案

当使用通配符时,它必须出现在refspec的两侧,所以 + refs / heads / *:refs / heads / master 不起作用。但您可以使用 + HEAD:refs / heads / master

  git config remote.heroku.push + HEAD:refs / heads / master 

另外,你可以这样做直接使用 git push

  git push heroku + HEAD:master 
git push - f heroku HEAD:master


Heroku has a policy of ignoring all branches but 'master'.

While I'm sure Heroku's designers have excellent reasons for this policy (I'm guessing for storage and performance optimization), the consequence to me as a developer is that whatever local topic branch I may be working on, I would like an easy way to switch Heroku's master to that local topic branch and do a "git push heroku -f" to over-write master on Heroku.

What I got from reading the "Pushing Refspecs" section of http://progit.org/book/ch9-5.html is

git push -f heroku local-topic-branch:refs/heads/master

What I'd really like is a way to set this up in the configuration file so that "git push heroku" always does the above, replacing local-topic-branch with the name of whatever my current branch happens to be. If anyone knows how to accomplish that, please let me know!

The caveat for this, of course, is that this is only sensible if I am the only one who can push to that Heroku app/repository. A test or QA team might manage such a repository to try out different candidate branches, but they would have to coordinate so that they all agree on what branch they are pushing to it on any given day.

Needless to say, it would also be a very good idea to have a separate remote repository (like GitHub) without this restriction for backing everything up to. I'd call that one "origin" and use "heroku" for Heroku so that "git push" always backs up everything to origin, and "git push heroku" pushes whatever branch I'm currently on to Heroku's master branch, overwriting it if necessary.

Would this work?

[remote "heroku"]
    url = git@heroku.com:my-app.git
    push = +refs/heads/*:refs/heads/master

I'd like to hear from someone more experienced before I begin to experiment, although I suppose I could create a dummy app on Heroku and experiment with that.

As for fetching, I don't really care if the Heroku repository is write-only. I still have a separate repository, like GitHub, for backup and cloning of all my work.

Footnote: This question is similar to, but not quite the same as Good Git deployment using branches strategy with Heroku?

解决方案

When using a wildcard, it had to be present on both sides of the refspec, so +refs/heads/*:refs/heads/master will not work. But you can use +HEAD:refs/heads/master:

git config remote.heroku.push +HEAD:refs/heads/master

Also, you can do this directly with git push:

git push heroku +HEAD:master
git push -f heroku HEAD:master

这篇关于如何将不同的本地Git分支推送到Heroku / master的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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